摆脱Android导航抽屉的半透明性

摆脱Android导航抽屉的半透明性,android,android-layout,Android,Android Layout,在我的应用程序中,我正在使用支持库中的导航抽屉。默认情况下,它是半透明的,设置它或其子对象的背景色只会添加此颜色的半透明版本。 这是抽屉和它的两个孩子: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_p

在我的应用程序中,我正在使用支持库中的导航抽屉。默认情况下,它是半透明的,设置它或其子对象的背景色只会添加此颜色的半透明版本。 这是抽屉和它的两个孩子:

 <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:background="@color/black">
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<ListView android:id="@+id/left_drawer_p"
    android:layout_width="500dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp"
    android:background="@color/grey"/>
</android.support.v4.widget.DrawerLayout>

我不太理解您的问题,但如果您试图使导航抽屉透明,请使用以下代码:

android:background="#60FFFFFF"
其中“60”的透明度约为38%(十六进制中的60表示十进制中的96,因此为96/255%)

但是,如果您的导航抽屉已经是透明的,我已经使用了代码:

android:background="#FFFFFF"
它工作正常,不透明


这两种颜色都是白色的HTML颜色代码,只需简单的谷歌搜索即可找到其他颜色的代码。

您希望
使用零alpha设置CrimColor

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.setScrimColor(Color.parseColor("#00FFFFFF"));

其中
R.id.drawer\u layout
是我的
DrawerLayout

我不应该在标题中说透明,对不起。listview中的android:background=@color/灰线指向一个十六进制代码,并控制背景颜色。它不是透明的,只是半透明的;i、 我可以看到listview下面的按钮。改变颜色没有帮助。我知道这很挑剔,但60%不是透明度。它是十六进制,表示96,从0到255,38%的半透明度也是如此。