0

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>

enter image description here

Community
  • 1
  • 1
Shahzeb
  • 3,696
  • 4
  • 28
  • 47
  • can you provide a screenshot? – petey Apr 25 '16 at 19:33
  • @petey sure. check update – Shahzeb Apr 25 '16 at 19:42
  • Try adding a layout_marginBottom on your LinearLayout that is the direct child of your ScrollView and see if it adjusts – Luke Villanueva Apr 25 '16 at 19:49
  • @ljpv14 didn't work. – Shahzeb Apr 25 '16 at 20:01
  • Are you using an `ActionBar` with `navigationMode` set to `NAVIGATION_MODE_TABS`? If so, please try to change this to using a `Toolbar` and a `TabLayout` instead as `ActionBar#setNavigationMode` is deprecated. – Darwind Apr 25 '16 at 22:38
  • @Darwind No navigation mode set. – Shahzeb Apr 26 '16 at 15:31
  • But you are using `ActionBar` with `Tabs` like this: `ActionBar.newTab()`? If so, try the layout with a Toolbar instead. I don't have any issues with your code, but I'm not using `Tab`s and the `ActionBar`. `Tab`s are deprecated. – Darwind Apr 26 '16 at 17:42
  • Ah I see that you've added the outer layout to your question now. It's a bit hard to figure out what the issue is if you don't add enough info from the beginning. Are you using `Fragment`s with your `ViewPager` or just views? – Darwind Apr 26 '16 at 17:45

2 Answers2

11

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

Atiq
  • 14,435
  • 6
  • 54
  • 69
  • The year is 2023, and this solution fixed my problem. Replacing `ScrollView` with `NestedScrollView` worked perfectly, even allowing a user to scroll in order to see the list of an `AutoCompleteTextView`. – Edward Quixote Feb 01 '23 at 09:52
1

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