Android 如何在一个LinearLayout中有多个ListView元素,所有元素都在NestedScrollview中?
正在尝试构建一个Android应用程序,其UI与Google Play Store相似:Android 如何在一个LinearLayout中有多个ListView元素,所有元素都在NestedScrollview中?,android,android-listview,android-coordinatorlayout,Android,Android Listview,Android Coordinatorlayout,正在尝试构建一个Android应用程序,其UI与Google Play Store相似: 使用向上滚动隐藏并使用向下滚动显示的应用程序栏 始终保持可见和可单击的选项卡栏 每个选项卡中有多个简单的UI元素,如ImageView和TextView 每个选项卡中有多个不同的ListView和GridView 前三个可以正常工作,但将任何类型的ListView(以及RecyclerView)放在LinearLayout内部,NestedScrollView的内部,只会显示第一个列表项,如文档所示:
- 使用向上滚动隐藏并使用向下滚动显示的应用程序栏
- 始终保持可见和可单击的选项卡栏
- 每个选项卡中有多个简单的UI元素,如ImageView和TextView
- 每个选项卡中有多个不同的ListView和GridView
<?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"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextColor="@android:color/white"
app:tabSelectedTextColor="@android:color/white"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="6dp"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
片段:
<FrameLayout 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"
tools:context="com.soletrade.grailsandroid.NewsFragment">
<android.support.v4.widget.NestedScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
不适用于在线性布局中显示多个ListView和GridView
任何帮助都会很棒,谢谢 为什么需要多个列表视图?你的屏幕截图可以通过一个ListView和顶部的一些按钮来实现。因为在我需要的项目中,在同一个选项卡中能够有一系列具有不同布局的ListView和GridView会很棒。只需要加载大量的表就可以了,但是多个ListView会使它变得简单。此外,在尝试使用顶部的简单按钮执行此操作时,它仅显示listview中的一个项目。