ale
ale

Reputation: 11820

Elements get hidden in ScrollView

I have the following:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout 
        android:id="@+id/layout_question_types"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="18sp"
        android:layout_marginTop="18sp"
        android:orientation="horizontal" >    
        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
            <!-- some content -->
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginRight="18sp"
            android:gravity="right"
            android:orientation="vertical" >
            <!-- some more content -->                                                   
        </RelativeLayout>
    </LinearLayout>
</ScrollView>

However, when I turn the phone horizontal to force the scrollbar, the scrollbar appears but the content at the bottom of the screen gets hidden.

Any ideas? There are similar questions on SO but they don't seem to fix the problem. Thanks.

Upvotes: 0

Views: 1309

Answers (1)

Josef Raška
Josef Raška

Reputation: 1301

Reason of this are margins and ScrollView parent FrameLayout which has some margin problems. Margins are ignored in measuring and scroll view measure its size without these margins and that is why the bottom part of inner views in ScrollView is not visible.

You can solve it simple wrapping child LinearLayout with another LinearLayout without margins.

Upvotes: 3

Related Questions