Javed Kadri
Javed Kadri

Reputation: 1

Android ScrollView

I am not sure why it won't scroll. I only have one Linear Layout and TextViews and some RadioButtons and I have encapsulated it inside the scroll view. So I have six textviews and five RadioGroups inside I have 3 radio buttons each. I tried everything, Please advice. Thanks in advance.

<ScrollView
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.android.quizcapitals.MainActivity">

        <TextView
            style="@style/Header_Text_Style"
            android:text="@string/test_knowledge" />


        <TextView
            style="@style/Header_Text_Style"
            android:text="@string/usa" />

        <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
            style="@style/Radio_Groups">

            <RadioButton
                android:id="@+id/newyork"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/newyork" />

            <RadioButton
                android:id="@+id/washington"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/Washington" />

            <RadioButton
                android:id="@+id/chicago"
                style="@style/Radio_Buttons"
                android:text="@string/chicago" />
        </RadioGroup>

        <TextView
            style="@style/Header_Text_Style"
            android:text="@string/germany" />

        <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
            style="@style/Radio_Groups">

            <RadioButton
                android:id="@+id/frankfurt"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/frankfurt" />

            <RadioButton
                android:id="@+id/berlin"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/berlin" />

            <RadioButton
                android:id="@+id/munich"
                style="@style/Radio_Buttons"
                android:text="@string/munich" />
        </RadioGroup>

        <TextView
            style="@style/Header_Text_Style"
            android:text="@string/france" />

        <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
            style="@style/Radio_Groups">

            <RadioButton
                android:id="@+id/paris"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/paris" />

            <RadioButton
                android:id="@+id/nice"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/nice" />

            <RadioButton
                android:id="@+id/marseille"
                style="@style/Radio_Buttons"
                android:text="@string/marseille" />
        </RadioGroup>

        <TextView
            style="@style/Header_Text_Style"
            android:text="@string/italy" />

        <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
            style="@style/Radio_Groups">

            <RadioButton
                android:id="@+id/venice"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/venice" />

            <RadioButton
                android:id="@+id/florence"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/florence" />

            <RadioButton
                android:id="@+id/rome"
                style="@style/Radio_Buttons"
                android:text="@string/rome" />
        </RadioGroup>

        <TextView
            style="@style/Header_Text_Style"
            android:text="@string/canada" />

        <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
            style="@style/Radio_Groups">

            <RadioButton
                android:id="@+id/toronto"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/toronto" />

            <RadioButton
                android:id="@+id/ottawa"
                style="@style/Radio_Buttons"
                android:onClick="onRadioButtonClicked"
                android:text="@string/ottawa" />

            <RadioButton
                android:id="@+id/montreal"
                style="@style/Radio_Buttons"
                android:text="@string/montreal" />
        </RadioGroup>


        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="finish"
            android:text="Finish"
            android:textAllCaps="true" />

    </LinearLayout>


</ScrollView>

Upvotes: 0

Views: 38

Answers (2)

Boulderbuff64
Boulderbuff64

Reputation: 56

Your ScrolView should have layout_height = "wrap_content"

<ScrollView
android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

Upvotes: 0

Clark Wilson
Clark Wilson

Reputation: 389

Try setting your LinearLayout's layout_height to wrap_content like so:

android:layout_height="wrap_content"

Upvotes: 1

Related Questions