Navigation Drawer - Have only icons and very big - android

I have a nav drawer implemented in my activity. The audience for my app is the elderly and I want the icons to be very large and take up the whole drawer height.
I am looking to have the 4 icons evenly spaced out and to have no text just big icons. I have tried playing around with the tag:
<dimen name="design_navigation_icon_size" tools:override="true"></dimen>
but I have not been able to get it to work. The icons simply keep overlapping each other when they get too big near the top. The images always seem to be contained in the header layout.

Create custom view and layout for drawer
<android.support.design.widget.NavigationView
android:id="#+id/nav_view_left"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_left" />
nav_header_left.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/right_side_header_bg_color"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:paddingTop="#dimen/fifty"
android:paddingRight="#dimen/twenty"
android:paddingLeft="#dimen/twenty"
android:orientation="vertical"
android:weightSum="4">
<TextView
android:id="#+id/add_txt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Gallery"
android:drawableLeft="#android:drawable/ic_menu_gallery"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="#+id/gall_txt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Gallery"
android:drawableLeft="#android:drawable/ic_menu_gallery"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="#+id/menu_add_txt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Gallery"
android:drawableLeft="#android:drawable/ic_menu_add"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="#+id/media_txt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:drawableLeft="#android:drawable/ic_media_rew"
android:gravity="center"
android:text="Gallery" />
</LinearLayout>

Use this code for navigationView:
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
android:theme="#style/AppTheme">
<android.support.design.widget.CoordinatorLayout
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">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/white"
android:titleTextColor="#color/theme_color_dark"
style="#style/AppTheme"
android:theme="#style/AppTheme"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<fragment
android:id="#+id/menu_fragement"
android:tag="Menu"
android:layout_width="250dp"
android:layout_gravity="start"
android:name="com.app.medcallz.fragments.MenuFragement"
android:layout_height="match_parent"
/>
</android.support.v4.widget.DrawerLayout>
MenuFragment:
<LinearLayout
android:id="#+id/options_container"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_below="#+id/user_detail_container">
<ImageView
android:id="#+id/notificationsIcon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/nav_notificatios"
android:layout_weight="0.1"/>
<View
android:id="#+id/account_divider"
android:layout_width="fill_parent"
android:layout_height="#dimen/login_divider_width"
android:background="#color/white_color"
android:visibility="visible"
/>
</LinearLayout>

Related

scrollview is not scrolling completly

In my main activity there is navigation drawer and fab button and inside content.xml which is the main xml to load content in my Main activity. In other word, I've navigation drawer activity provided by android studio.
Code in that content.xml is:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="#+id/b1"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#f0eb79"
android:foreground="?attr/selectableItemBackground"
android:drawableTop="#drawable/computer"
android:paddingTop="25dp"
android:text="Chemistry"
android:textAllCaps="false"
android:textColor="#2f2e2e"
android:textSize="18sp" />
<Button
android:id="#+id/b2"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#524d47"
android:foreground="?attr/selectableItemBackground"
android:drawableTop="#drawable/computer"
android:paddingTop="25dp"
android:text="Sports"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="#+id/b3"
android:layout_width="0dp"
android:foreground="?attr/selectableItemBackground"
android:layout_height="200dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#e7595d"
android:drawableLeft="#drawable/computer"
android:paddingLeft="45dp"
android:text="Inventions"
android:textAllCaps="false"
android:textColor="#fff"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
And it is not completely scrolling as shown in the figure below. I also tested same xml code into another empty activity where there is NOT fab and nagivation drawer and there it is showing scrolling behaviour perfectly.
Similarly, this is my activitymain.xml's code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.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">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
It worked for me after adding these attribute in scrollview:
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.nepali_test.MainActivity"
tools:showIn="#layout/app_bar_main"

How to add two Button in Navigation Drawer and on each Button show Different Menu Items

Please help me to make a navigation drawer with two menus and two different button to inflate the each Menu Items and click listener
Below is the Mock up and I want to make drawer like these
Navigation Drawer First Button View
Navigation Drawer Second Button View
Please check this, it will help to add a custom view. You can use tablayout and view pager
I have read your question very carefully and try to make this layout. Finally i make it .
try this code to achieve your layout
activity_home_navigation_activtiy
<?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">
<include
layout="#layout/app_bar_home_navigation_activtiy"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--<include layout="#layout/nav_header_home_navigation" />-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".28"
android:background="#color/colorPrimary"
android:gravity="bottom"
android:orientation="vertical"
android:paddingLeft="15dp"
android:paddingBottom="15dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/navigation_user_img"
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/ic_launcher_foreground" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/navigation_user_name_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Picks App"
android:textColor="#504C4C"
android:textSize="17dp"
android:textStyle="italic" />
<TextView
android:id="#+id/navigation_user_email_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Last Name"
android:textColor="#000"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/navigation_nested"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".72"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<Button
android:id="#+id/usr_bt"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="User"/>
<Button
android:id="#+id/admin_bt"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:text="Admin"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/user_recyler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:paddingLeft="15dp"
android:scrollbars="none" />
<android.support.v7.widget.RecyclerView
android:id="#+id/admin_recyler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:paddingLeft="15dp"
android:scrollbars="none" />
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
In this layout i try to make custom drawable . you can also customize according to your need
see screen shot
Thank You

Top ActionBar covers pages content

I'm creating an android app and I've just added a Navigation drawer into one of my activities. I've successfully added it in, however, it now overlaps the content of the page. The jobs text and the rest should be below the ActionBar.
I've tried adding a margin to the top of the jobs text which does push it down as I wish. Is there a better way to move it down?
<?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">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout 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/jobListPage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
tools:context="com.kitkat.crossroads.Jobs.JobsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Jobs"
android:fontFamily="#font/bebasneueregular"
android:textSize="30dp"
android:textAlignment="center"
tools:layout_editor_absoluteX="163dp"
tools:layout_editor_absoluteY="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textName"
android:layout_width="125dp"
android:layout_height="50dp"
android:layout_marginLeft="60dp"
android:fontFamily="#font/bebasneueregular"
android:gravity="center_vertical"
android:text="Job Name"
android:textSize="15dp"
android:textColor="#FF000000"
android:visibility="visible" />
<TextView
android:id="#+id/textFrom"
android:layout_width="100dp"
android:layout_height="50dp"
android:fontFamily="#font/bebasneueregular"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/textName"
android:gravity="center_vertical"
android:text="From"
android:textSize="15dp"
android:textColor="#FF000000"
android:visibility="visible" />
<TextView
android:id="#+id/textTo"
android:layout_width="100dp"
android:layout_height="50dp"
android:fontFamily="#font/bebasneueregular"
android:textSize="15dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:text="To"
android:textColor="#FF000000"
android:visibility="visible" />
</LinearLayout>
<ExpandableListView
android:id="#+id/jobListView12345"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<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:fitsSystemWindows="true"
app:headerLayout="#layout/navigation_header"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Becoz you assign the gravity="top" in Linearlayout so its happens
so u remove this gravity see my below code:
<LinearLayout 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/jobListPage"
android:layout_width="match_parent"
android:layout_height="match_parent"
//remove gravity="top" from hear
tools:context="com.kitkat.crossroads.Jobs.JobsActivity">
if your problem not solve then u can take android:layout_marginTop="20dp" in inner Linearlayout
see below code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="vertical">
Don't take a include in LinearLayout. Becoz its change your actionbar so u can only remove gravity and assign margin top
I believe you should put
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
inside
<LinearLayout
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/jobListPage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
tools:context="com.kitkat.crossroads.Jobs.JobsActivity">
The reason why I was having the overlap was because I put the page content in the activity_main.xml layout and not the content_main.xml. Putting the content in that layout sorted the issue out and put the content below the action bar.

Navigation Drawer (SlidingMenu) is not working properly

I'm using DrawerLayout in my Activity .xml is given below :
<?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">
<!-- The first child in the layout is for the main Activity UI-->
<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"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#09436B"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:background="#F1F1F1"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/tab_selected_text_color"
app:tabTextColor="#color/tab_text_color" />
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/tab_layout"></android.support.v4.view.ViewPager>
</RelativeLayout>
<!-- Side navigation drawer UI -->
<LinearLayout
android:id="#+id/layout_navigation_drawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.almabay.almachat.circularImageView.CircularImageView
android:id="#+id/imgUser"
android:layout_width="100dp"
android:layout_height="100dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/txtNameUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txtEmaiIDUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/margin10"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txtProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/profile" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txtAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/accounts" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txtNotification"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/notification" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txtContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/contacts" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txtChats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/chats" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txtHelp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/help" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/margin10" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/txtLogout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/logout" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
But I'm getting the correct Navigation drawer.No hamburger icon is shown
I want to implement the following screen:
Please guide me where i am doing mistake.I know that inside DrawerLayout one view is for the main content of the screen and other is for Navigation Drawer items.I have studied various examples which shows i have to use the list view for the items of navigation drawer but i can not use list view here as i have to fix my design .
I would suggest you to use navigation view (put it on the bottom of drawer layout) and put your items in it.
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start">
<include layout="#layout/your navigation view layout"/>
</android.support.design.widget.NavigationView>

Add Footer to CoordinatorLayout

I want to add a Footer to CoordinatorLayout which contains a TabView + ViewPager.
Here is the 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 is the 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 is in xml content.
If i remove:
app:layout_behavior="#string/appbar_scrolling_view_behavior"
in the main Xml View Pager, footer appears , else it's not shown.
How can i get the footer visible?
You already 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 for both height and width which it doesn't seems to be good.
Also, Perhaps you will need to show that ViewPager with NestedScrollView for scrolling the content in future.(needs a trick, but you can achieve this).
So, my suggest is, you should be able to show that footer all the time in the below of that ViewPager by adding it like 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 to 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 the footer all the time (even when ViewPager is collapsing).
Or if you want to show it in your ViewPager:
you should add this in your contents:
app:layout_behavior="#string/appbar_scrolling_view_behavior"
Which means, it will put the contents below the AppbarLayout
Anyways, your contents problem is coming from that GridView like i said, it will match all the content and you don't have ScrollView or even NestedScrollView to show the other contents.

Categories

Resources