我在Android應用中使用Google's support design library v25.1.0實施Bottom Navigation Bar。有什麼方法可以添加投影效果,與當前Android本機Google相冊應用相同?Android底部導航欄帶陰影
9
A
回答
27
您可以使用簡單的查看和背景繪製自己的影子正上方的底欄:
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_above="@id/bottom_bar"
android:background="@drawable/shadow"/>
繪製/ shadow.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#1F000000"
android:endColor="@android:color/transparent"
android:angle="90" />
</shape>
而且,沒有兼容性問題,如果使用這種方法。
2
您可以使用標高陰影添加到任何視圖
<TextView
android:id="@+id/myview"
...
android:elevation="2dp"
android:background="@drawable/myrect" />
參考this瞭解更多信息
+0
在我的項目中不起作用:「屬性」提升「僅用於API級別21和更高(當前最小值爲16)」,如果確實有效,則會使用該屬性。 –
相關問題
- 1. 如何刪除底部陰影的的導航欄在swift3
- 2. 陰影變色導航欄
- 3. Android:從底部導航中刪除陰影
- 4. 底部陰影到ListPopupWindow android
- 5. 底部導航欄
- 6. 的Android - 導航欄取代我的底部導航欄
- 7. Appcelerator Android新底部導航欄
- 8. 導航欄隱藏NestedScrollView的底部[Android]
- 9. Pinterest導航欄框陰影css
- 10. 與添加一個陰影導航欄
- 11. 如何刪除導航欄的陰影
- 12. 創建底部導航欄
- 13. jQuery Mobile底部導航欄
- 14. 導航欄飛到底部
- 15. Android底部導航
- 16. 如何在底部增加圓形陰影導航
- 17. Android:將陰影應用於ImageView底部
- 18. Android - 底部導航視圖和導航欄內的片段
- 19. 缺少導航欄和底部欄
- 20. 如何陰影底部
- 21. UINaviguationBar底部陰影消失
- 22. CollectionView底部的陰影
- 23. 導航欄狀態,顯示和隱藏底部導航欄
- 24. 的Android底部導航
- 25. Google即時狀態欄和導航欄上的漸變/陰影
- 26. 桌面導航欄粘頂部粘底
- 27. 導航欄顯示在底部
- 28. Bootstrap底部滾動導航欄
- 29. jQuery Mobile的導航欄底部
- 30. 導航控制器底部欄
的最佳解決方案。謝謝。 – Ahsan
適合與舊版Android兼容 –