2014-02-12 55 views
2

我正在爲混合文本和圖像輸入創建一個活動。 這裏是容器的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或者這是內存限制?

回答

1

使用ListView自定義佈局(每行)而不是混合使用ScrollView和LinearLayout會更好嗎?

如果你想添加噸圖像(就像一個畫廊),你可以考慮使用LRUCache或其他算法(即延遲加載)。

另外,還要考慮你特林加載到內存中的圖像大小。也許較小的尺寸和每個項目的「點擊放大」應該是一個更好的方法/ UX

+1

謝謝,它有幫助! – Doge

+0

不客氣。對你的問題+1 – MatheusJardimB

相關問題