Android中ScrollView内部带有ListLayout的LinearLayout
我想完整的屏幕滚动除了广告。但该列表视图显示一个项目,如果高度是填充内容或包装内容。仅在该场景中滚动列表视图Android中ScrollView内部带有ListLayout的LinearLayout,android,android-layout,android-scrollview,Android,Android Layout,Android Scrollview,我想完整的屏幕滚动除了广告。但该列表视图显示一个项目,如果高度是填充内容或包装内容。仅在该场景中滚动列表视图 <?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=
<?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>
我尝试了填充内容/包装内容,但没有任何效果
我有超过50项在列表视图,但我想滚动屏幕与线性布局也
谢谢。请尝试以下代码
<?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>
谢谢NikHil,但在scrollview android:layout_over=“@id/list_view”-行中给出一个错误,该list_视图不是同一相对性的同级视图它与以前的布局显示相同,只是在每个滚动条目的一个项目上滚动列表视图。不滚动整个屏幕,除了ads`“android:layout\u width=“match\u parent”android:layout\u height=“match\u parent”android:fillViewport=“true”xmlns:app=”“app:layout\u behavior=“@string/appbar\u滚动\u视图\u behavior”“>`--如果我使用nestedscroll而不是scrollviewListview,它也不起作用。ListView将自动包含滚动条。这可能是它考虑作为嵌套滚动视图的原因,但是如果我想要滚动视图和包含线性布局和列表布局的完整页面,该怎么办