简体   繁体   中英

View doesn't show the last +- 50dp of the content in Android

I have been following the a toturial to make a material design with tabs from Android Hive .

Now I am trying to add a ScrollView in a fragment. The fragment is added to the ViewPager. But it does not show the last +-50 dp of the content in ScrollView. I think it is somewhere in the layout_height propperty but i do not know how to fix this.

activity_main.xml:

<?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.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <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/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />
</android.support.design.widget.CoordinatorLayout>

Fragment_one.xml:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/scroll"
     android:layout_height="fill_parent"
     android:layout_width="fill_parent"
     tools:context="com.a42.pthong.philips.CompanyFragment">

     <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_margin="@dimen/activity_horizontal_margin"
          android:orientation="vertical">

          <TextView
               android:text="@string/title"
               android:id="@+id/textView"
               android:textSize="20sp"
               android:textStyle="bold"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" />
          <TextView
               android:id="@+id/content1"
               android:text="@string/content"
               android:textSize="12sp"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" />

     </LinearLayout>

</ScrollView>

This is because you are using CoordinatorLayout with ScrollView . Change your implementation to android.support.v4.widget.NestedScrollView to achieve correct scroll.

CoordinatorLayout scroll works properly with the children of NestedScrollingChild .

Same sort of question was answered here by me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM