【发布时间】:2016-01-04 07:06:35
【问题描述】:
我试图将 RecyclerView 放在 ScrollView 中,我在 recycler 视图上方有布局,所以我想滚动布局和 回收器。
在我的主布局中,我有两个子布局,一个有 recyclerView,另一个有一个图像。两个布局都在 scrollView 内。当我在布局中向上滚动时,我想同时滚动
我知道我们不能在一个布局中放置两个滚动视图的问题。 我正在搜索是否有任何逻辑可以scroll layout 和recycler View
布局.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/backgorund"
android:weightSum="1">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:id="@+id/layout_top_balance"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".25">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/txt_balance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="35dp"
android:textColor="@color/black"
android:text="$60 USD"/>
<TextView
android:layout_below="@+id/txt_balance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="20dp"
android:textColor="#828282"
android:text="Account Balance"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_feeds"
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingLeft="16dp"
android:paddingBottom="5dp"
android:layout_weight=".75">
<view
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="android.support.v7.widget.RecyclerView"
android:id="@+id/recycler_view"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
请任何人帮忙解决这个问题:)
【问题讨论】:
-
RecyclerView它自己一个ScrollView -
在我的主布局中,我有两个子布局,一个有recyclerView,另一个有一个图像。两个布局都在滚动视图内。当我在布局中向上滚动时,我想同时滚动 @IntelliJ Amiya
-
@BinilS 您可以将这些部分添加为 RecyclerView 的标题
-
或者你可以自定义你附加到recyclerview的布局管理器并使用
NestedScrollView
标签: android android-layout android-recyclerview android-scrollview android-scroll