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