HorizontalScrollView嵌套RecyclerVi
2021-09-07 本文已影响0人
hao_developer
修改之前:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_22">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/flYuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_5">
<TextView
android:id="@+id/tvCumulativeMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/red_circle_line_shape"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_2"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_2"
android:text="已累计986元"
android:textColor="@color/red_eb"
android:textSize="@dimen/sp_14" />
<ImageView
android:layout_width="@dimen/dp_10"
android:layout_height="@dimen/dp_5"
android:layout_gravity="center|bottom"
android:layout_marginTop="@dimen/dp_22"
android:adjustViewBounds="true"
android:src="@mipmap/down_arrow" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_below="@+id/flYuan"
android:id="@+id/rlProList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false" />
</LinearLayout>
</HorizontalScrollView>
修改之后
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_22">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/flYuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_5">
<TextView
android:id="@+id/tvCumulativeMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/red_circle_line_shape"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_2"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_2"
android:text="已累计986元"
android:textColor="@color/red_eb"
android:textSize="@dimen/sp_14" />
<ImageView
android:layout_width="@dimen/dp_10"
android:layout_height="@dimen/dp_5"
android:layout_gravity="center|bottom"
android:layout_marginTop="@dimen/dp_22"
android:adjustViewBounds="true"
android:src="@mipmap/down_arrow" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_below="@+id/flYuan"
android:id="@+id/rlProList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false" />
</RelativeLayout>
</HorizontalScrollView>
后来在recyclerView外边的LinearLayout改成Relativelayout布局解决了问题。
当时我试过使用Linerlayout作为其父布局,没有成功。为什么使用Relativelayout就可以,估计得看两个layout
的源码才能了解了