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

8
  • can you provide a screenshot? Commented Apr 25, 2016 at 19:33
  • @petey sure. check update Commented Apr 25, 2016 at 19:42
  • Try adding a layout_marginBottom on your LinearLayout that is the direct child of your ScrollView and see if it adjusts Commented Apr 25, 2016 at 19:49
  • @ljpv14 didn't work. Commented Apr 25, 2016 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. Commented Apr 25, 2016 at 22:38

2 Answers 2

12

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.