[英]How to set transparency of Navigation drawer background?
我需要能夠將背景設置為完全透明。 似乎以前沒有人嘗試過。 請幫忙。
如果我正確,我們需要使framelayout背景完全透明。 但這樣做沒有任何影響。
感謝你的所有回應,但到目前為止它們似乎都沒有。
為了進一步澄清,我需要使listview下面的背景透明。
也就是說,當抽屜完全打開時。可以看到來自下面活動的部分屏幕。 它顯示為模糊的灰色,一些文字可見。 我需要它完全可見。
我是否需要更改活動中的某些主題?
以下是完整的布局xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navDraweLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/headerLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/headerBlue"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="10dp" >
<Button
android:id="@+id/drawer_btn"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:background="@color/logoutBtnBlue"
android:onClick="drawerBtnClicked"
android:padding="5dp"
android:textColor="@color/white" />
<TextView
android:id="@+id/headerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="PeepApp"
android:textColor="@color/white"
android:textSize="25dp" />
<Button
android:id="@+id/logout_btn"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:background="@color/logoutBtnBlue"
android:onClick="logoutBtnClicked"
android:padding="5dp"
android:text="Logout"
android:textColor="@color/white" />
</RelativeLayout>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="1"
android:background="@android:color/transparent"
>
<FrameLayout
android:id="@+id/content_frame"
android:alpha="0.3"
android:background="#00000000"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--
android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
The drawer is given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view.
-->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/logoutBtnBlue"
android:choiceMode="singleChoice"
android:divider="@android:color/white"
android:dividerHeight="1dp" />
</android.support.v4.widget.DrawerLayout>
不知道我是否了解你,我會試一試。 讓我們來看看。 如果我沒弄錯的話,你看不到抽屜本身。 你看到的是里面的ListView。 因此,為了將其背景設置為透明,您需要做的就是設置
android:background="@android:color/transparent"
到您的ListView XML。
這將使它完全不可見,但如果你想要一些顏色的透明度,你可以在這里使用接受的答案來選擇正確的值。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.