ScrollView not Scrolling - Android

僤鯓⒐⒋嵵緔 提交于 2019-11-27 23:02:23

Put an empty view with fixed height

<View
                android:layout_width="match_parent"
                android:layout_height="50dp" />

as your last item in the linear layout which is a child of scroll view..

This worked for me..

The child view of a ScrollView should be set to wrap_content. If you set it to match_parent, it will fill the area of the ScrollView and never scroll, because it won't be larger than the ScrollView.

Try changing the child LinearLayout layout_height to either wrap_content or a specific size (in dp) instead of match_parent.

Your ScrollView child needs to have its height as wrap_content :

<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:animateLayoutChanges="true"
    android:orientation="vertical"
    android:scrollbars="vertical" >

    ... 
    ...
</LinearLayout>
</ScrollView>

You should set the height of LinearLayout (child of Scrollview) to wrap_content.

When the child is taller than the ScrollView, then android:fillViewport="true" attribute has no effect.

I was able to solve it by adding (android:windowSoftInputMode="adjustResize|stateHidden") in the activity manifest, like below

<activity
            android:name=".ui.main.MainActivity"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustResize|stateHidden"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar">
        </activity> 
<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

Remove android:fillViewport="true" from above element

use Table Layout instead of linear layout something like this:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:fadeScrollbars="false" android:padding="6dip">
<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1"
    >   
   //your stuff 
</TableLayout>
</ScrollView>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!