我創建了以實現類似於在1:18的人在這個視頻中的滑動菜單擴展ViewGroup中的自定義佈局:https://www.youtube.com/watch?v=YeR7McJIltk如何調暗自定義佈局的背景?
不過,我不知道該怎麼做的是暗淡的背景當菜單滑動內容
我創建了以實現類似於在1:18的人在這個視頻中的滑動菜單擴展ViewGroup中的自定義佈局:https://www.youtube.com/watch?v=YeR7McJIltk如何調暗自定義佈局的背景?
不過,我不知道該怎麼做的是暗淡的背景當菜單滑動內容
你可以做這樣的事情:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
//your views are here
</LinearLayout>
<View
android:id="@+id/dim"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cc000000" />
</RelativeLayout>
,讓您的dim
FrameLayout
可見,只有當菜單被打開,看不見的,當它關閉
將視圖頂部的佈局充滿黑色或灰色背景在性能方面,使用任何佈局(如使用的FrameLayout) ,還是普通的「View」? –
感謝您回答我的想法和您的方法。是什麼讓我不願意使用這種方法是我不能逐漸調暗背景。一旦你在上面添加framelayout,那麼背景就會變暗。有沒有辦法使我的背景逐漸變暗,而黑暗程度取決於滑動菜單的打開程度? – JustCurious
@KevinMurvie我相信視圖應該更快,因爲'FrameLayout'是視圖類的後裔。我會更新我的答案。 – Divers
使用'setAlpha(Float);' –