android - Setting a margin for NavigationDrawer items -
my problem can't correctly set margin in navigation drawer. have tried changing margin of view , item doesn't seem work out. space between actionbar , navigationdrawer (and beginning of page). think problem inside listitem layout not sure. photo of get
and layout , code files.
main layout
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/drawer_layout"> <android.support.v4.widget.swiperefreshlayout android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/refreshsites" tools:context=".myactivity"> <android.support.v7.widget.recyclerview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/siteslist" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="5dp"/> </android.support.v4.widget.swiperefreshlayout> <relativelayout android:layout_width="280dp" android:layout_height="fill_parent" android:id="@+id/drawerpane" android:layout_gravity="start"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:layout_margintop="15dp"> <listview android:id="@+id/left_drawer" android:layout_width="280dp" android:layout_height="match_parent" android:layout_gravity="start" android:choicemode="singlechoice" android:divider="@android:color/white" android:dividerheight="0dp" android:layout_marginleft="15dp" android:background="#fff"> </listview> </linearlayout> </relativelayout> </android.support.v4.widget.drawerlayout>
drawer_list_item.xml
<?xml version="1.0" encoding="utf-8"?> <textview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="50dp" android:layout_margintop="15dp" android:layout_marginstart="50dp" android:textappearance="?android:attr/textappearancelarge" android:textcolor="#222"/>
my piece of code works navigationdrawer
mdrawerlayout = (drawerlayout) findviewbyid(r.id.drawer_layout); mdrawerlist = (listview) findviewbyid(r.id.left_drawer); mdrawerlist.setadapter(new arrayadapter<string>(this, r.layout.drawer_list_item, mplanettitles)); //mplanettitles string array
so question is: how set these margins correctly?
try item
<textview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#fff" android:padding="20dp" android:textappearance="?android:attr/textappearancelarge" android:textcolor="#222" android:text="bla bla bla" />
and main xml this
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/drawer_layout"> <android.support.v4.widget.swiperefreshlayout android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/refreshsites" tools:context=".myactivity"> <android.support.v7.widget.recyclerview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/siteslist" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="5dp"/> </android.support.v4.widget.swiperefreshlayout> <relativelayout android:layout_width="280dp" android:layout_height="fill_parent" android:id="@+id/drawerpane" android:layout_gravity="start"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <listview android:id="@+id/left_drawer" android:layout_width="280dp" android:layout_height="match_parent" android:layout_gravity="start" android:choicemode="singlechoice" android:divider="@android:color/white" android:dividerheight="0dp" android:background="#fff"> </listview> </linearlayout> </relativelayout>
hope, help.
Comments
Post a Comment