i want add footer coordinatorlayout
contains tabview + viewpager
.
here main.xml:
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:opendrawer="start"> <android.support.design.widget.coordinatorlayout android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context="com.entree.entree.activity.storeactivity"> <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingtop="@dimen/appbar_padding_top" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="@android:color/black" app:layout_scrollflags="scroll|enteralways" app:popuptheme="@style/apptheme.popupoverlay"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_tray" android:layout_gravity="right" android:layout_marginright="15dp" android:scaletype="centerinside"/> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_find" android:layout_gravity="right" android:scaletype="centerinside" android:layout_marginright="10dp" /> </android.support.v7.widget.toolbar> <android.support.design.widget.tablayout android:id="@+id/tabs" android:background="@android:color/white" app:tabindicatorcolor="#00000000" style="@style/mycustomtablayout" android:layout_width="match_parent" android:layout_height="wrap_content" /> </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:layout_above="@+id/lltray" /> </android.support.design.widget.coordinatorlayout> <android.support.design.widget.navigationview android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:visibility="gone" android:fitssystemwindows="true" app:headerlayout="@layout/nav_header_search" app:menu="@menu/activity_search_drawer" /> </android.support.v4.widget.drawerlayout>
and here xml content:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/container" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.entree.entree.activity.storeactivity$placeholderfragment"> <gridview android:id="@+id/gridview" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:numcolumns="1" android:stretchmode="columnwidth"> </gridview> <linearlayout android:id="@+id/lltray" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightsum="3" android:visibility="gone" android:gravity="center_vertical" android:layout_centervertical="true" android:background="@color/divider" android:layout_alignparentbottom="true"> <relativelayout android:layout_width="wrap_content" android:layout_weight="1" android:layout_gravity="left" android:gravity="left" android:layout_height="wrap_content"> <imagebutton android:id="@+id/btntray" android:src="@drawable/ic_action_tray_menu" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </relativelayout> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="20sp" android:textstyle="bold" android:layout_gravity="center_horizontal|center_vertical" android:gravity="center_horizontal|center_vertical" android:layout_weight="1" android:text="@string/view_tray" /> <relativelayout android:layout_width="wrap_content" android:layout_weight="1" android:gravity="right" android:layout_marginright="10dp" android:layout_height="wrap_content"> <textview android:id="@+id/tvtotalprice" android:layout_width="wrap_content" android:textsize="20sp" android:textstyle="bold" android:text="@string/rs" android:layout_height="wrap_content" /> </relativelayout> </linearlayout>
the footer in xml content.
if remove:
app:layout_behavior="@string/appbar_scrolling_view_behavior"
in main xml view pager
, footer appears , else it's not shown.
how can footer visible?
you have:
<gridview android:id="@+id/gridview" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:numcolumns="1" android:stretchmode="columnwidth" />
with match_parent
both height
, width
doesn't seems good.
also, perhaps need show viewpager
nestedscrollview
scrolling content in future.(needs trick, can achieve this).
so, suggest is, should able show footer time in below of viewpager
adding this:
<android.support.v4.view.viewpager android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:layout_above="@+id/lltray" /> <!-- footer aligned bottom --> <relativelayout android:id="@+id/footer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:background="#fc0" android:gravity="center" app:layout_anchor="@id/main_content" app:layout_anchorgravity="bottom"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="fixed footer" android:textcolor="#000" android:textsize="20sp" /> </relativelayout> </android.support.design.widget.coordinatorlayout>
this should show footer time (even when viewpager
collapsing).
or if want show in viewpager
:
you should add in contents:
app:layout_behavior="@string/appbar_scrolling_view_behavior"
which means, put contents below appbarlayout
anyways, contents problem coming gridview
said, match content , don't have scrollview
or nestedscrollview
show other contents.
Comments
Post a Comment