Why is my Android navigation drawer opening too wide? -
i had rather basic navigation drawer working pretty -- simple listview. need title above selectable items, (see below) modified xml drawer relativelayout containing textview title , listview items.
what resulted quite strange. though have specified width 3 (relativelayout, textview , listview) 240dp, width of listview when represented entire drawer's xml, looks (ignore volume control - didn't see pop up). notice listview 240 dp wide, red background i've assigned going way right.
here's xml first screen. relevant drawer xml @ bottom.
<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"> <!-- main content view --> <relativelayout 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:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:background="@drawable/ail_background_gradient" tools:context="com.allinlearning.assist_android.homescreenactivityfragment"> <imageview android:id="@+id/imgviewlogo" android:src="@drawable/ail_logo" android:layout_margin="10dp" android:layout_width="90dp" android:layout_height="90dp" android:scaletype="fitxy" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="all in learning" android:id="@+id/textviewlogo" android:layout_margin="10dp" android:layout_below="@+id/imgviewlogo" android:layout_centerhorizontal="true" android:textsize="@dimen/font_size26" android:textstyle="bold" /> <imagebutton android:id="@+id/imgbtngradeassessment" android:src="@drawable/grade_assessment" android:layout_width="100dp" android:layout_height="95dp" android:scaletype="fitxy" android:layout_centervertical="true" android:layout_toleftof="@+id/textviewgradeassessment" android:layout_tostartof="@+id/textviewgradeassessment" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="grade" android:id="@+id/textviewgradeassessment" android:textcolor="@color/white" android:textsize="@dimen/font_size28" android:layout_centervertical="true" android:layout_alignright="@+id/imgviewlogo" android:layout_alignend="@+id/imgviewlogo" /> <imagebutton android:id="@+id/imgbtnprivatedata" android:src="@drawable/two_clickers" android:layout_width="100dp" android:layout_height="95dp" android:scaletype="fitxy" android:layout_below="@+id/imgbtngradeassessment" android:layout_alignleft="@+id/imgbtngradeassessment" android:layout_alignstart="@+id/imgbtngradeassessment" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="private data" android:id="@+id/textviewprivatedata" android:textcolor="@color/white" android:textsize="@dimen/font_size28" android:layout_alignbottom="@+id/imgbtnprivatedata" android:layout_torightof="@+id/imgbtnprivatedata" android:layout_toendof="@+id/imgbtnprivatedata" android:layout_marginbottom="40dp" /> </relativelayout> <!-- navigation drawer --> <linearlayout android:id="@+id/left_drawer" android:orientation="vertical" android:background="@color/red" android:layout_width="240dp" android:layout_height="wrap_content"> <textview android:layout_width="240dp" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="i title" android:id="@+id/tvdrawertitle" android:layout_margin="10dp" android:layout_centerhorizontal="true" android:textsize="@dimen/font_size26" android:textstyle="bold" android:textalignment="center" android:textcolor="@color/black" /> <listview android:id="@+id/lvdraweritems" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="left" android:choicemode="singlechoice" android:divider="@android:color/transparent" android:dividerheight="0dp" android:background="@color/white" /> </linearlayout> </android.support.v4.widget.drawerlayout>
the layout_gravity
attribute determines child view
acts drawer in drawerlayout
. currently, neither of direct children of drawerlayout
has attribute set, both filling it, linearlayout
on top, covering content relativelayout
.
move android:layout_gravity="left"
listview
linearlayout
.
Comments
Post a Comment