ScrollView not Scrolling - Android

前端 未结 7 1216
孤独总比滥情好
孤独总比滥情好 2020-12-06 02:13

I can\'t understand why this is happening. I am unable to scroll my scrollview. It has a textView, an imageview and few linear layouts inside of it. When I replace the image

相关标签:
7条回答
  • 2020-12-06 02:21

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

    0 讨论(0)
  • 2020-12-06 02:23

    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>
    
    0 讨论(0)
  • 2020-12-06 02:27

    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> 
    
    0 讨论(0)
  • 2020-12-06 02:28

    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.

    0 讨论(0)
  • 2020-12-06 02:29

    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.

    0 讨论(0)
  • 2020-12-06 02:30

    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>
    
    0 讨论(0)
提交回复
热议问题