farnholdt
farnholdt

Reputation: 173

How to make LinearLayout content scroll?

Im trying to scroll some content inside a linearlayout and the outer layout is as relativelayout that includes a header and a bottom menu.

How to make it scrollable ?

This is my current layout. But nothing happens in scrolling the linearlayout section.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">

<include layout="@layout/header_guide"
    android:id="@+id/GuideHeaderInclude"
    android:layout_alignParentTop="true"
    />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/GuideHeaderInclude"
android:isScrollContainer="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/GuideContentHolder">
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/guidecard"
    android:layout_gravity="center_horizontal"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/GuideRegCardHeader"
    android:layout_gravity="center_horizontal"
    style="@style/OnlineAboutHeaderStyle"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/GuideRegCardText"
    style="@style/OnlineAboutTextStyle"
    />
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/guidemap"
    android:layout_gravity="center_horizontal"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/GuideMapHeader"
    android:layout_gravity="center_horizontal"
    style="@style/OnlineAboutHeaderStyle"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/GuideMapText"
    style="@style/OnlineAboutTextStyle"
    />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/guidelist"
    android:layout_gravity="center_horizontal"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/GuideVerifyHeader"
    android:layout_gravity="center_horizontal"
    style="@style/OnlineAboutHeaderStyle"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/GuideVerifyText"
    style="@style/OnlineAboutTextStyle"
    />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/guidecashback"
    android:layout_gravity="center_horizontal"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/GuideCashbackHeader"
    android:layout_gravity="center_horizontal"
    style="@style/OnlineAboutHeaderStyle"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/GuideCashbackText"
    style="@style/OnlineAboutTextStyle"
    />
</LinearLayout>
</ScrollView>
<include layout="@layout/bottom_menu"
    android:id="@+id/GuideBottomMenu"
    android:layout_alignParentBottom="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</RelativeLayout>

Upvotes: 1

Views: 97

Answers (1)

Hareshkumar Chhelana
Hareshkumar Chhelana

Reputation: 24848

Try this way,hope this will help you to solve your problem.

<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white">

    <include layout="@layout/header_guide"
        android:id="@+id/GuideHeaderInclude"/>
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:isScrollContainer="true">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/GuideContentHolder">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/guidecard"
                android:layout_gravity="center_horizontal"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/GuideRegCardHeader"
                android:layout_gravity="center_horizontal"
                style="@style/OnlineAboutHeaderStyle"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/GuideRegCardText"
                style="@style/OnlineAboutTextStyle"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/guidemap"
                android:layout_gravity="center_horizontal"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/GuideMapHeader"
                android:layout_gravity="center_horizontal"
                style="@style/OnlineAboutHeaderStyle"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/GuideMapText"
                style="@style/OnlineAboutTextStyle"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/guidelist"
                android:layout_gravity="center_horizontal"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/GuideVerifyHeader"
                android:layout_gravity="center_horizontal"
                style="@style/OnlineAboutHeaderStyle"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/GuideVerifyText"
                style="@style/OnlineAboutTextStyle"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/guidecashback"
                android:layout_gravity="center_horizontal"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/GuideCashbackHeader"
                android:layout_gravity="center_horizontal"
                style="@style/OnlineAboutHeaderStyle"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/GuideCashbackText"
                style="@style/OnlineAboutTextStyle"/>
        </LinearLayout>
    </ScrollView>
    <include layout="@layout/bottom_menu"
        android:id="@+id/GuideBottomMenu"/>
</LinearLayout>

Upvotes: 3

Related Questions