【问题标题】:Lag for multiple images in single scrollview单个滚动视图中多个图像的滞后
【发布时间】:2014-02-12 23:05:07
【问题描述】:

我正在创建一个混合文本和图像输入的活动。 这是容器的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 或者这是内存限制?

【问题讨论】:

    标签: android image imageview richtextbox lag


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-15
      • 1970-01-01
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-09
      相关资源
      最近更新 更多