Android应用程式上卡片检视的影格速率问题

在卡片视图中滚动时,我遇到巨大的帧频/跳帧。我在某处读到这可能是因为我将图像直接加载到页面中,而不是使用Picasso,但不确定是否会有所帮助。想知道是否有人曾经经历过这种情况并且知道如何解决?

  <androidx.cardview.widget.CardView
        android:id="@+id/cardview1"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:layout_below="@+id/cardview"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="16dp"
        app:cardBackgroundColor="@color/white"
        app:cardCornerRadius="15dp"
        app:cardElevation="10dp">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

        </LinearLayout>

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:gravity="center_horizontal"
            android:paddingLeft="10dp"
            android:text="Green Torso"
            android:textColor="@color/cardview_dark_background"
            android:textSize="20sp"
            android:textStyle="bold" />

        <ImageView
            android:id="@+id/ShopGreenTorso"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/green_torso"/>

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_gravity="bottom"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/register_button"
            android:shadowColor="@color/colorPrimary"
            android:text="20S Buy"
            android:textColor="@color/white">
        </Button>
    </androidx.cardview.widget.CardView>

这是我的代码,但我只显示了一个cardview来使代码简短。其他5个与此相同,只是具有不同的图像。

先谢谢大家。

Android应用程式上卡片检视的影格速率问题

c2125102 回答:Android应用程式上卡片检视的影格速率问题

确定是我的设备运行缓慢;给正在开发移动应用程序的任何人的建议是确保在多个设备上进行测试。它在LG G3上运行不太流畅,但是在OnePlus 3T上却完美无缺。我敢肯定那里有可以优化这一点的人,但是对于大多数休闲应用程序开发人员来说,切换设备可以解决问题。

本文链接:https://www.f2er.com/2989484.html

大家都在问