android - Can I use the same frame layout (as container) to display DrawerLayout and RecyclerView? -
i have navigation drawer using recyclerview
layout. in same time, main page use recyclerview
layout too. how manage optimally?
this activity_main.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <!--toolbar--> <include android:id="@+id/toolbar_actionbar" layout="@layout/toolbar_default" android:layout_width="match_parent" android:layout_height="wrap_content" /> <!-- recyclerview commonly used attributes --> <android.support.v7.widget.recyclerview android:id="@+id/my_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" /> <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:baselinealignbottom="true" android:layout_marginbottom="12dp" android:src="@mipmap/ic_action_good" /> <!--mulai layout drawer--> <android.support.v4.widget.drawerlayout android:id="@+id/drawer" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar_actionbar"> <framelayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true"> </framelayout> <!--fragment drawer--> <fragment android:id="@+id/fragment_drawer" android:name="com.mundane.hortipedia.navigationdrawerfragment" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent" android:layout_gravity="start" app:layout="@layout/fragment_navigation_drawer" /> </android.support.v4.widget.drawerlayout>
i want fetch data sqlite database , show them r.id.my_recycler_view. doesn't work.
try main layout, per android guidelines drawerlayout must root container first child container of drawerlayout main page , second child drawer.
<?xml version="1.0" encoding="utf-8"?> <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"> <framelayout android:id="@+id/fl_main_container" android:layout_width="fill_parent" android:layout_height="fill_parent"> <!-- recyclerview commonly used attributes --> <android.support.v7.widget.recyclerview android:id="@+id/my_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" /> <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:baselinealignbottom="true" android:layout_marginbottom="12dp" android:src="@mipmap/ic_action_good" /> <!--toolbar--> <include android:id="@+id/toolbar_actionbar" layout="@layout/toolbar_default" android:layout_width="match_parent" android:layout_height="wrap_content" /> </framelayout> <!--framelayout drawer--> <framelayout android:id="@+id/fl_drawer_container" android:layout_width="give desired width here" android:layout_height="fill_parent"> <android.support.v7.widget.recyclerview android:id="@+id/my_recycler_view2" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" /> </framelayout> </android.support.v4.widget.drawerlayout>
i hope help
Comments
Post a Comment