如何在 android 中设计复杂的 UI
How to design complex UI in android
如何在 RecyclerView 之上放置一个 ViewPager,或者在一个 ScrollView 中放置多个 RecyclerView?我设计了下面的布局,但是在滚动的时候出现了一些问题。
问题是什么,我该如何解决?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:background="#dcdcdc"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ActivityMain"
tools:showIn="@layout/app_bar_main">
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="200dip"
/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
</ScrollView>
我已经尝试 compile 'com.bartoszlipinski:recyclerviewheader2:2.0.1'
和
<com.bartoszlipinski.recyclerviewheader2.RecyclerViewHeader
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top">
1-首先它支持11 sdk或更高版本,
2-其次 ViewPager
不会在 header RecyclerView
中工作。
我试过 RecyclerView
layout_width="wrap_content"
但它只在 sdk21 中受支持。
如何解决 RecyclerView 滚动问题?
尝试去掉顶部的 ScrollView 并使用 ListView 而不是 RecyclerView。
ScrollView 在这里是不必要的,你需要一个 hack 来让 ViewPager 与 RecyclerView 一起工作,因为它会消耗所有触摸事件。如果您可以使用 ListView,那就更简单了。
您可以将您的视图分页器带到折叠工具栏布局中的应用栏,这样就可以了
如何在 RecyclerView 之上放置一个 ViewPager,或者在一个 ScrollView 中放置多个 RecyclerView?我设计了下面的布局,但是在滚动的时候出现了一些问题。 问题是什么,我该如何解决?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:background="#dcdcdc"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ActivityMain"
tools:showIn="@layout/app_bar_main">
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="200dip"
/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
</ScrollView>
我已经尝试 compile 'com.bartoszlipinski:recyclerviewheader2:2.0.1'
和
<com.bartoszlipinski.recyclerviewheader2.RecyclerViewHeader
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top">
1-首先它支持11 sdk或更高版本,
2-其次 ViewPager
不会在 header RecyclerView
中工作。
我试过 RecyclerView
layout_width="wrap_content"
但它只在 sdk21 中受支持。
如何解决 RecyclerView 滚动问题?
尝试去掉顶部的 ScrollView 并使用 ListView 而不是 RecyclerView。
ScrollView 在这里是不必要的,你需要一个 hack 来让 ViewPager 与 RecyclerView 一起工作,因为它会消耗所有触摸事件。如果您可以使用 ListView,那就更简单了。
您可以将您的视图分页器带到折叠工具栏布局中的应用栏,这样就可以了