Android - Easy/comfortable way to design DrawerLayout using Android Studio? -
Android - Easy/comfortable way to design DrawerLayout using Android Studio? -
in app have implementer drawerlayout
1 of activities, , added listview
in center of activity. in order add together items (button
s , textview
etc..) add together them manually editing xml layout file (by adding raw attributes page). there way design drawer in android studio design simple activity
? added screen shot of how looks in studio, elements appear on left of page, outside of emulator.
edit: here xml layout:
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- first kid in layout main activity ui--> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity" android:background="#ffffffff"> <listview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listviewchat" android:layout_centerhorizontal="true" android:choicemode="multiplechoice" /> </relativelayout> <!-- side navigation drawer ui --> <relativelayout android:id="@+id/drawercontainer" android:layout_width="270dp" android:layout_height="match_parent" android:layout_gravity="left|start" android:background="@drawable/splash_background_blur" android:focusable="true" android:focusableintouchmode="true" android:clickable="true"> <!--this custom view serves dimmer drawer--> <view android:layout_width="match_parent" android:layout_height="match_parent" android:background="#73000000" android:id="@+id/view1" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:focusableintouchmode="true"/> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/edittextusername" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="160dp" android:cursorvisible="false" android:textcolor="#fff" android:textsize="20sp" android:background="@null" android:maxlength="15" android:inputtype="textnosuggestions" android:hint="enter user name"/> <button android:layout_width="220dp" android:layout_height="35dp" android:text="@string/buttonselectphoto" android:id="@+id/buttontakephoto" android:background="@drawable/splash_button" android:textcolor="#fff" android:layout_margintop="200dp" android:layout_marginleft="25dp" android:layout_marginstart="25dp"/> <button android:layout_width="220dp" android:layout_height="35dp" android:text="@string/buttontakephoto" android:id="@+id/buttonselectphoto" android:background="@drawable/splash_button" android:textcolor="#fff" android:layout_margintop="250dp" android:layout_marginleft="25dp" android:layout_marginstart="25dp" android:layout_alignparentstart="true"/> <button android:layout_width="220dp" android:layout_height="35dp" android:text="@string/buttontakeatour" android:id="@+id/buttontaketour" android:background="@drawable/splash_button" android:textcolor="#fff" android:layout_margintop="300dp" android:layout_marginleft="25dp" android:layout_marginstart="25dp"/> <!-- <listview android:id="@+id/navlist" android:layout_width="match_parent" android:layout_height="match_parent"/> <linearlayout android:focusable="true" android:focusableintouchmode="true" android:layout_width="0px" android:layout_height="0px" />--> </relativelayout> </android.support.v4.widget.drawerlayout>
edit i split content of drawer separate xml
file , tried add together content using <include>
tag. when click on "hamburger" (open drawer) icon app crashes java.lang.illegalargumentexception: no drawer view found gravity left
error. wrong layout?
the activity utilizes drawerlayout
, include
s new stand lone layout (drawer content):
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- first kid in layout main activity ui--> <include layout="@layout/drawer_layout_and_content"/> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity" android:background="#ffffffff"> <listview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listviewchat" android:layout_centerhorizontal="true" android:choicemode="multiplechoice" /> </relativelayout> </android.support.v4.widget.drawerlayout>
here's custom layout used drawer in main activity: (drawer_layout_and_content.xml)
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="250dp" android:layout_height="match_parent" android:background="@drawable/splash_background_blur" android:id="@+id/drawercontainer"> <view android:layout_width="match_parent" android:layout_height="match_parent" android:background="#73000000" android:id="@+id/view1" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:focusableintouchmode="true"/> <button android:layout_width="220dp" android:layout_height="35dp" android:text="@string/buttonselectphoto" android:id="@+id/buttontakephoto" android:background="@drawable/splash_button" android:textcolor="#fff" android:layout_margintop="200dp" android:layout_marginleft="25dp" android:layout_marginstart="25dp"/> </relativelayout>
you can utilize include
key word that. first, create layout file called drawer_content.xml
, <include layout="@layout/drawer_content">
. code drawer_content.xml
layout file of activity
or fragment
. , if want know more details, check here.
android android-studio drawerlayout
Comments
Post a Comment