Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get rid of Android navigation drawer translucency

In my app, I'm using the navigation drawer from the support library. It is translucent by default, and setting it or its childrens' background color just adds a translucent version of this color. This is the drawer and its two children:

 <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>
like image 291
user2651167 Avatar asked Aug 04 '13 20:08

user2651167


2 Answers

You want to setScrimColor with zero alpha.

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

where R.id.drawer_layout is the id of my DrawerLayout

like image 148
Jason White Avatar answered Nov 18 '22 20:11

Jason White


I dont really understand your question, but if you are trying to make the navigation drawer transparent then use the following code:

android:background="#60FFFFFF"

Where the '60' is about 38% transparency (60 in hex is 96 in decimal, so 96/255 %).

But if your navigation drawer is already transparent I have used the code:

android:background="#FFFFFF"

It works fine and it is not transparent.

Both colours are the HTML colour code for white, a simple google search will find you the code for other colours.

like image 5
Patrick Dibb Avatar answered Nov 18 '22 22:11

Patrick Dibb