2016-07-26 67 views

回答

0

你可以做這樣的事情:

<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> 

,讓您的dimFrameLayout可見,只有當菜單被打開,看不見的,當它關閉

+0

將視圖頂部的佈局充滿黑色或灰色背景在性能方面,使用任何佈局(如使用的FrameLayout) ,還是普通的「View」? –

+0

感謝您回答我的想法和您的方法。是什麼讓我不願意使用這種方法是我不能逐漸調暗背景。一旦你在上面添加framelayout,那麼背景就會變暗。有沒有辦法使我的背景逐漸變暗,而黑暗程度取決於滑動菜單的打開程度? – JustCurious

+0

@KevinMurvie我相信視圖應該更快,因爲'FrameLayout'是視圖類的後裔。我會更新我的答案。 – Divers