Skip to content Skip to sidebar Skip to footer

Android Navigationdrawer Transparency

I’ve implemented NavigationDrawer with android-support-v4 as per this tutorial My result is on this screenshot. The question is how to remove or configure these transparency on D

Solution 1:

You need to add alpha to your ListView. Use your XML and extend the ListView definition with alpha-attribute.

<ListView
     android:id="@+id/left_drawer"
     android:layout_width="240dp"
     android:layout_height="match_parent"
     android:layout_gravity="start"
     android:choiceMode="singleChoice"
     android:divider="@android:color/transparent"
     android:dividerHeight="0dp"
     android:background="#111111"
     android:alpha="255"
/>

Solution 2:

Use this in you code. Get the background of the drawer view and set alpha for it.

Drawablebackground= drawerView_.getBackground();
  background.setAlpha(255);

Solution 3:

Thanks everyone who tried to answer my question. I'm sorry the trouble was in Fragment initialization in code.

So I've tried to add fragment as new instance, but it should be just a replacement of already defined fragment in layout as follows:

android.support.v4.app.FragmentManagerfragmentManager= getSupportFragmentManager();
FeedFragmentfragment=newFeedFragment();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

now everything works fine.

Solution 4:

To make navigation drawer transparent, you must first define the color for your drawer in res/values/colors.xml file. Eg:<color name="navigationDrawerNew">#7ba9530c</color>

Now, on the left side of this line, the color that you have chosen will be displayed in a small square.

See image for example

Click on it. It will bring up a color chooser. In the color chooser, at the bottom, there is a slider which allow you to adjust transparency. Adjust it to get the required transparency. Now, set this color as background color for the list view for navigation drawer in xml file. The list view looks almost like this:-

<ListView
    android:id="@+id/navList"
    android:layout_width="200dp"
    android:layout_height="match_parent"
    android:layout_gravity="left|start"
    android:background="@color/navigationDrawerNew" />

Solution 5:

Set the Background of the Drawer (Which in the linked demo is a ListView) to a solid color/drawable

Post a Comment for "Android Navigationdrawer Transparency"