在android中回收视图+卡片视图滚动不当行为

问题描述

当我开始向上/向下滚动元素或视图开始变得混乱时,我的活动中有一个回收视图。

这是我的 layout.xml ?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@color/background_color"
    android:orientation="vertical"
    android:tag="cards main container"
    android:padding="5dp">

    <androidx.cardview.widget.CardView
       android:id="@+id/card_view"
       android:layout_width="match_parent"
       android:layout_height="70dp"
       android:padding="10dp"
   app:cardBackgroundColor="@color/white"
   android:orientation="horizontal" >

   <ImageView
       android:id="@+id/expense_category_img"
       android:layout_width="40dp"
       android:layout_height="50dp"
       android:layout_margin="10dp"
       android:src="@drawable/ic_baseline_shopping_bag_24" />

   <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_marginStart="60dp"
       android:layout_marginTop="10dp"
       android:layout_marginEnd="10dp"
       android:orientation="vertical">

       <TextView
           android:id="@+id/expense_category"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginTop="5dp"
           android:text="@string/category_create_budget"
           android:textColor="@color/black"
           android:textStyle="bold" />

       <TextView
           android:id="@+id/currentAmountText"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginTop="5dp"
           android:text="@string/amount_add"
           android:textColor="@color/grey" />

       <TextView
           android:id="@+id/currentAmount"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginStart="60dp"
           android:layout_marginTop="-20dp"
           android:text="@string/r2000_68_amount"
           android:textColor="@color/grey" />


       <ImageView
           android:id="@+id/add"
           android:layout_width="30dp"
           android:layout_height="30dp"
           android:layout_gravity="end"
           android:layout_marginTop="-40dp"
           android:layout_marginEnd="10dp"
           android:src="@drawable/ic_baseline_add_circle_24" />

   </LinearLayout>

在此处输入代码

具有回收视图的那个

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical"
    android:padding="10dp">

    <androidx.cardview.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        app:cardBackgroundColor="@color/white"
       android:orientation="horizontal"
        >

        <ImageView
            android:id="@+id/expense_category_img"
            android:layout_width="40dp"
            android:layout_height="50dp"
            android:layout_margin="10dp"
            android:src="@drawable/ic_baseline_shopping_bag_24"
            android:contentDescription="@string/todo__" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="60dp"
            android:layout_marginTop="10dp"
            android:layout_marginEnd="10dp"
            android:orientation="vertical">

            <TextView
                android:id="@+id/expense_category"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:text="@string/category_create_budget"
                android:textColor="@color/black"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/current_month_Amount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="0dp"
                android:layout_marginTop="10dp"
                android:text="@string/r2000_68_amount"
                android:textColor="@color/grey" />


            <ImageView
                android:id="@+id/trend"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="end"
                android:layout_marginTop="-40dp"
                android:layout_marginEnd="10dp"
                android:contentDescription="@string/todo__"
                android:src="@drawable/ic_baseline_trending_up_24" />

        </LinearLayout>

 </androidx.cardview.widget.CardView>

</LinearLayout>

滚动前 enter image description here

滚动后 enter image description here

如果我的问题不成立,请原谅我,提前致谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)