I want to make my NavigationDrawer just like in this app
and more specifically, I want to add that little 1 pixel border on the right side
but here is what I am getting with my drawer
and this is the xml of the drawer fragment
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E7E7E7"
android:choiceMode="singleChoice"
android:dividerHeight="0.5dp" />
What do I have to do?
How to create a custom navigation drawer in Android? This example demonstrate about How to resize Image in Android App. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml.
With the navigation drawer one can navigate to many screens or functionalities of the app by clicking on the ‘hamburger’ icon. Swiping from the left is also a way to bring the drawer into view, a screen then slides in, showing many items.
They are elevated above most of the app’s UI and don’t affect the screen’s layout grid. They are primarily for use on mobile where screen space is limited, and can be replaced by standard drawers on tablet and desktop. The following example shows a modal navigation drawer with a top app bar.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to res/layout/nav_header_main.xml.
Try this,
DrawerLayout mDrawerLayout;
onCreate(Bundle ...){
//...
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
GravityCompat.START);
//...
}
EDIT
You need to add one View
along with ListView
and wrap both with one LinearLayout
horizontally and give both some weight. Here I have given 0.99
weight to listView
and 0.01
weight to view
, you can change it as per your requirement.
<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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ListView android:id="@+id/drawer_list"
android:layout_weight="0.99"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E7E7E7"
android:choiceMode="singleChoice"
android:dividerHeight="0.5dp" />
<View
android:layout_weight="0.01"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#eeccbb"/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With