0
votes

I wan't to create a FragmentStatePagerAdapter for that my layouts need(need?) to be ScrollView at toplevel. Now when I create my layout the LinearLayout ( or RelativeLayout doesn't matter ) never uses the full scrollview-container, even though I set layout_height and layoutg_width to "match_parent" ( fill_parent or wrap_content doesn't do the trick either ) Here is part of the layout

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/intro_scroll_view_1"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:orientation="vertical"
        android:background="@drawable/intro_dummy">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".80"
            android:layout_gravity="center_horizontal">

            <ImageView
                android:layout_width="223dp"
                android:layout_height="60dp"
                android:id="@+id/imageView"
                android:layout_centerVertical="true"
                android:layout_centerHorizontal="true"
                android:src="@drawable/logo"/>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".20"
            android:layout_gravity="center_horizontal">

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_above="@+id/button">

            </RelativeLayout>

            <Button
                android:background="@null"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Get Started"
                android:id="@+id/button"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:textColor="#ffffff"
                android:padding="2dp"/>

        </RelativeLayout>

    </LinearLayout>
</ScrollView>

Since I use match_parent it should use the whole screen? Nope it only uses a random bit of the screen

enter image description here

If I remove the Scrollview and just make the LinearLayout the toplevel-element it uses everything. So I am guessing I am missing something in the Scrollview description to make it use everything?

1

1 Answers

1
votes

Use

android:fillViewport="true"

In your ScrollView, http://developer.android.com/reference/android/widget/ScrollView.html#attr_android:fillViewport

Defines whether the scrollview should stretch its content to fill the viewport.