0

I want complete screen scroll-able except ads. But that list view shows one item if height is fill-content or wrap content. Only list view scroll in that scenario.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#eeeeee">
<android.support.v7.widget.CardView
    android:id="@+id/playback_error"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:animateLayoutChanges="true"
    android:visibility="gone">

    <TextView
        android:id="@+id/error_message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/error_message_background"
        android:gravity="center"
        android:paddingBottom="@dimen/error_vertical_padding"
        android:paddingLeft="@dimen/error_horizontal_padding"
        android:paddingRight="@dimen/error_horizontal_padding"
        android:paddingTop="@dimen/error_vertical_padding"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        tools:text="Connectivity error!" />
</android.support.v7.widget.CardView>
<com.google.android.gms.ads.doubleclick.PublisherAdView xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/verve_sdk_ad_unit_id"></com.google.android.gms.ads.doubleclick.PublisherAdView>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/adView">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            >

            <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/linearLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#ffffff"
                android:orientation="vertical"
                android:padding="5dp">

                <ImageView
                    android:id="@+id/categoryImage"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
                <TextView
                    android:id="@+id/categoryTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="1"
                    android:textColor="#000000"
                    android:textSize="20dp"
                    android:text="The Best Music"/>
                <TextView
                    android:id="@+id/categoryDesc"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:maxLines="5"
                    android:textColor="#000000"
                    android:text="test description" />
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="15dp"
                    android:background="@drawable/textlines"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:paddingBottom="20dp"
                    android:paddingLeft="10dp"
                    android:paddingTop="15dp"
                    android:text="Episodes / Tracks"
                    android:textColor="#ffffff"
                    android:textSize="30dp"
                    tools:background="#272727"
                    tools:text="Episodes / Tracks" />
            </LinearLayout>
            <!--<android.support.v7.widget.Toolbar-->
                <!--android:id="@+id/toolbar"-->
                <!--android:layout_width="match_parent"-->
                <!--android:layout_height="?attr/actionBarSize"-->
                <!--app:layout_collapseMode="pin"-->
                <!--app:popupTheme="@style/ThemeOverlay.AppCompat.Light"-->
                <!--app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"/>-->
        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <LinearLayout
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:id="@+id/list_view"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

I tried fill-content/wrap content, but nothing working.

I have more than 50 item in list view but i want to scroll screen with linear layout also.

Thanks.

0

1 Answer 1

1

Try the following code

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.rorkom.nikhil.scrolltest.ScrollingActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:toolbarId="@+id/toolbar">
            <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/linearLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#ffffff"
                android:orientation="vertical"
                android:padding="5dp">
                <ImageView
                    android:id="@+id/categoryImage"
                    android:src="@drawable/ic_launcher_background"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
                <TextView
                    android:id="@+id/categoryTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="1"
                    android:textColor="#000000"
                    android:textSize="20dp"
                    android:text="The Best Music"/>
                <TextView
                    android:id="@+id/somedesc"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:maxLines="5"
                    android:textColor="#000000"
                    android:text="John Doe, his brothers, his sisters, his pets and his more than amazing band" />
            </LinearLayout>
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
    <LinearLayout
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:text="Add"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="100dp" />
        <ListView
            android:id="@+id/list_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </ListView>
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Sign up to request clarification or add additional context in comments.

13 Comments

Thanks NikHil, but in scrollview android:layout_above="@id/list_view" - line giving an error, that list_view is not a sibling for same relativelayout
Its same as previous layout display, just scrolling list view at a one item each scroll. Not scrolling complete screen except ads
` <android.support.v4.widget.NestedScrollView xmlns:android="schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" xmlns:app="schemas.android.com/apk/res-auto" app:layout_behavior="@string/appbar_scrolling_view_behavior" >` -- Its also not working if i used nestedscroll instead of scrollview
Listview will automatically contain scrollbar. This might be the reason for it considering as nested scroll view
But what if i want scroll view with complete page which include linear layout and list layout
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.