gpt4 book ai didi

android - 单个 ScrollView 中的多个图像滞后

转载 作者:行者123 更新时间:2023-11-29 00:23:05 26 4
gpt4 key购买 nike

我正在创建混合文本和图像输入的 Activity 。这是容器的 xml。

<ScrollView
android:id="@+id/new_question_body_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/new_question_tag_container"
android:layout_above="@+id/oler_keyboard_accessory"
android:layout_alignLeft="@+id/new_question_tag_container"
android:layout_alignRight="@+id/new_question_tag_container"
android:scrollbars="none">

<LinearLayout
android:id="@+id/new_question_body_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<EditText
android:id="@+id/new_question_body_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="Please edit your body here."
android:layout_marginBottom="5dp"/>

</LinearLayout>
</ScrollView>

动态添加三个(不滞后两个)imageViews 后,滚动时变得非常滞后。即使我为每个单独的 50dp 设置 maxHeight 和 Width,延迟仍然存在。我是以错误的方式添加 imageView 还是这是内存限制?

最佳答案

使用 ListView 不会更好使用自定义布局(针对每一行)而不是混合使用 ScrollView 和 LinearLayout?

如果您想添加大量图片(就像画廊一样),您可以考虑使用 LRUCache或其他算法(即延迟加载)。

此外,请考虑您要加载到内存中的图像大小。也许每个项目的较小尺寸和“点击缩放”应该是更好的方法/UX

关于android - 单个 ScrollView 中的多个图像滞后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21741831/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com