I have the xml-file with CoordinatorLayout
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible"
android:gravity="center_horizontal">
<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="wrap_content">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp">
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
app:tabBackground="#drawable/my_tab_item_bg_selector"
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabMode="fixed"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
And I have another xml-file which I put on coordinator layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/nestedScrollData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="#+id/layoutDataDispatchContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
<LinearLayout
android:id="#+id/layoutFullTableDispatchContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="#drawable/layout_block_background">
<LinearLayout
android:id="#+id/tableLinearLayoutDispatchContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
I catching bug of empty space, which covers the part of my window and not clickable. This is on screenshot below:
unclickable inactive bottom space
I noticed that when I deleting app:layout_behavior="#string/appbar_scrolling_view_behavior" from my ViewPager, the bug disappears. But my names of tabs disappear too. I think it creates some invisible toolbar or something like that.
As CoordinatorLayout is working as parent of subviews so, to occupy full screen you need to set the height to match parent instead of wrap_content like this:
android:layout_height="match_parent"
and it would work fine.
Related
The bottom button/some view hides the list view bottom part.
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView 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:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="example.design.activities.DetailsActivity"
android:background="#color/grey">
<android.support.v7.widget.RecyclerView
android:paddingTop="80dp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:gravity="bottom">
<!-- Add to cart button -->
<android.support.v7.widget.AppCompatButton
android:id="#+id/ssssss"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="ADD TO CART"
android:backgroundTint="#color/colorPrimary"
android:textColor="#color/white"
android:layout_alignParentBottom="true"
android:visibility="visible" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
I will make the bottom view visible and invisible based on condition.
How can I adjust my list view to scroll more if the bottom bar is visible ?
I think this will solve your problem,
<?xml version="1.0" encoding="utf-8"?>
<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.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:fillViewport="true"
android:background="#android:color/darker_gray">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent"
android:layout_above="#+id/ssssss"/>
<!-- Add to cart button -->
<android.support.v7.widget.AppCompatButton
android:id="#+id/ssssss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="ADD TO CART"
android:layout_alignParentBottom="true"
android:backgroundTint="#color/colorPrimary"
android:textColor="#android:color/white"
android:visibility="visible" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
here is the sample output
NOTE:
you have added android:fitsSystemWindows="true" and so you need android:paddingTop="80dp" in your recycler view.Instead you can follow as in my solution just give android:fillViewport="true" to nestedScrollView and no padding needed for recyclerview.
I hope this solves your issue
You can add android:clipToPadding = "false" in your NestedScrollView.
And when you are showing your bottom button you can dynamically add bottom padding for NestedScrollview with value equals to height of your bottom button.
nestedScrollView.setPadding(yourPadding, yourPadding,yourPadding, btn.getMeasuredHeight())
You should change NestedScrollView by using layout_anchor as below.
<android.support.v4.widget.NestedScrollView 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:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="example.design.activities.DetailsActivity"
android:background="#color/colorPrimary"
app:layout_anchor="#+id/relative_view"
app:layout_anchorGravity="top">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:paddingTop="80dp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
It put scrollview on top of your bottom bar as per your aspect.
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.widget.NestedScrollView 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EAEAEA"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="example.design.activities.DetailsActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Add to cart button -->
<android.support.v7.widget.AppCompatButton
android:id="#+id/ssssss"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:backgroundTint="#color/colorPrimary"
android:padding="20dp"
android:text="ADD TO CART"
android:textColor="#FFFFFF"
android:visibility="visible" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/ssssss"
android:layout_alignParentTop="true"
android:paddingTop="80dp" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
I have a Coordinator Layout showing cardview, I wanted to show TextView above this coordinator layout, I tried putting Coordinator Layout inside Linear Layout just like how we do for Frame Layout, but that didn't work. Can someone help
Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:comfort="http://schemas.android.com/tools"
android:id="#+id/main_content"
android:background="#color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Hello World"
android:textColor="#color/eula_body_text_color"
android:textSize="19sp" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:tabStripEnabled="false"
android:layout_height="wrap_content"/>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="#dimen/_16sdp"
android:paddingLeft="12dp"
android:paddingRight="-12dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Hello World"
android:textColor="#color/eula_body_text_color"
android:textSize="19sp" />
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:comfort="http://schemas.android.com/tools"
android:id="#+id/main_content"
android:background="#color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:tabStripEnabled="false"
android:layout_height="wrap_content"/>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="#dimen/_16sdp"
android:paddingLeft="12dp"
android:paddingRight="-12dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
Main Problem is you want textview outside the coordinatorlayout but you are defining as child of that layout. So, you need to create a parent layout which have two childs i.e. 1. TextView and 2. CoordinatorLayout.
<LinearLayout>
<TextView/>
<CoordinatorLayout>
all Views
</CoordinatorLayout>
</LinearLayout>
I have a strange problem with my BottomNavigationBar
The situations is this:
I have an activity that contains
- A little Fragment for showing Debts and Credits and it works
- A listView with all my expenditures and it works as well
- A bottomNavigationMenuBar that work partially, indeed it is not anchored to the bottom of my activity but if stay at the bottom of the ListView untill the ListView occupy all the space on the display
I attach some screen to explain better
no good behaviour, it must stay at the bottom
ListView is bigger than the screen and it works good
Here is my XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/tab_bck"
xmlns:design="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:id="#+id/LinearVerticalLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/tab_bck" >
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="#+id/expenseToolbar"
android:layout_height="?attr/actionBarSize"
android:elevation="6dp"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextColor="#android:color/white"
app:subtitleTextColor="#android:color/white"
android:background="#color/colorPrimary">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/></android.support.v7.widget.Toolbar>
<FrameLayout
android:id="#+id/fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="it.polito.mad17.viral.sliceapp.Fragment_of_money"
/>
<ListView
android:id="#+id/listView2"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:background="#color/tab_bck"
android:longClickable="true"
/>
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/bottom_nav_bar"
android:layout_gravity="bottom"
design:menu="#menu/bottom_nav_bar_menu"
design:itemIconTint="#16a085"
design:itemTextColor="#16a085"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Put your BottomBar outside the Linear Layout. Like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/tab_bck"
xmlns:design="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:id="#+id/LinearVerticalLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/tab_bck" >
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="#+id/expenseToolbar"
android:layout_height="?attr/actionBarSize"
android:elevation="6dp"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextColor="#android:color/white"
app:subtitleTextColor="#android:color/white"
android:background="#color/colorPrimary">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/></android.support.v7.widget.Toolbar>
<FrameLayout
android:id="#+id/fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="it.polito.mad17.viral.sliceapp.Fragment_of_money"
/>
<ListView
android:id="#+id/listView2"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:background="#color/tab_bck"
android:longClickable="true"
/>
</LinearLayout>
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/bottom_nav_bar"
android:layout_gravity="bottom"
design:menu="#menu/bottom_nav_bar_menu"
design:itemIconTint="#16a085"
design:itemTextColor="#16a085"/>
</android.support.design.widget.CoordinatorLayout>
This should work for you
Try giving LinearVerticalLayout's android:layout_height="match_parent", may be it'll work
I am trying to add a custom header in my main activity that already contains a bottom navigator and a framelayout that acts as a container for the fragments i want to display.
The below given code contains a Linearlayout["#+id/application_header] that should act as the application header, however the header is displayed by the fragment container[#+id/main_container] is overlapping the header.
Tried the properties android:layout_below and android:layout_above but it is still overlapping.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:design="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.amplitude.tron.volksradio.MainActivity">
<LinearLayout
android:id="#+id/application_header"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RADIO"
android:layout_gravity="center"/>
</LinearLayout>
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/application_header"
android:layout_above="#+id/bottomNavigationBar"
android:layout_alignParentTop="true">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomNavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
design:menu="#menu/bottom_menu_navigation"
android:background="#50b1b5b9">
</android.support.design.widget.BottomNavigationView>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/application_header"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RADIO"
android:layout_gravity="center"/>
</LinearLayout>
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/application_header"
android:layout_above="#+id/bottomNavigationBar"
android:layout_alignParentTop="true">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomNavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
design:menu="#menu/bottom_menu_navigation"
android:background="#50b1b5b9">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
android:layout_below and android:layout_above work with RelativeLayout. BTW, the LinearLayout with only one TextView is redundant. You can just use TextView. Here are some options on how to get that done.
Using RelativeLayout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:design="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/application_header"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="RADIO"/>
</LinearLayout>
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottomNavigationBar"
android:layout_alignParentTop="true"
android:layout_below="#id/application_header">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomNavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#50b1b5b9"
design:menu="#menu/bottom_menu_navigation">
</android.support.design.widget.BottomNavigationView>
</RelativeLayout>
Using LinearLayout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:design="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/application_header"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="RADIO"/>
</LinearLayout>
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomNavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#50b1b5b9"
design:menu="#menu/bottom_menu_navigation">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
One more (better) alternative would be using CoordinatorLayout with Toolbar:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:design="http://schemas.android.com/tools">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/application_header"
android:layout_above="#+id/bottomNavigationBar"
android:layout_alignParentTop="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomNavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
design:menu="#menu/bottom_menu_navigation"
android:background="#50b1b5b9"/>
</android.support.design.widget.CoordinatorLayout>
Solved it my self, although there might other clean solution and would be accepted as answer if found feasible.
I just added android:layout_marginTop="50dp" which is same as the height of element with id - #+id/application_header
PS- i don't know if this would effect screens with different sizes and my testing device is only 5.5 inches to which the solution worked perfectly.
You can also make the layout align center of the screen by adding this :
android:layout_centerInParent="true"
also add a padding or margin incase there is any small amount of overlapping
Before you mark it duplicate, let me tell you that I have searched for every answer but all in vain.
I am using Tabs with Actionbar.
I have set android:layout_height="match_parent" of ScrollView as suggested in many solutions.
I also have removed android:layout_gravity="center" from all layouts as suggested by:
Android scrollview hiding top content in layout
I also have set android:fillViewport="true" but no luck.
Any other hack that I am missing?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<CalendarView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/calendarView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Guest"/>
<NumberPicker
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</NumberPicker>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title_time_slot"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title_add_on"/>
<Button
android:id="#+id/btn_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/title_btn_confirm"/>
</LinearLayout>
</ScrollView>
Here is xml of activity:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.squincy.wspace.ui.HomeActivity">
<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="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextColor="#color/app_color_black"
app:tabTextAppearance="#android:style/TextAppearance.Widget.TabWidget"
app:tabIndicatorColor="#color/app_color_black"
app:tabGravity="center"
app:tabMode="scrollable"/>
</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.support.design.widget.FloatingActionButton-->
<!--android:id="#+id/fab"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="end|bottom"-->
<!--android:layout_margin="#dimen/fab_margin"-->
<!--android:src="#android:drawable/ic_dialog_email" />-->
</android.support.design.widget.CoordinatorLayout>
I think you should try NestedScrollView
<android.support.v4.widget.NestedScrollView
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:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
Just replace your ScrollView with this one
I am using it in my app and it works perfectly
Try adding paddingBottom to your LinearLayout inside ScrollView.
If that doesn't work then try adding Space as last child of LinearLayout inside ScrollView like this:
<ScrollView
<LinearLayout
// other views
<Space
android:layout_width="match_parent"
android:layout_height="required_spacing_in_dp" />
</LinearLayout>
</ScrollView