开发者

Large bitmap under a ListView/ScrollViews slows the scrolling

开发者 https://www.devze.com 2023-03-31 12:53 出处:网络
I have the following layout <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"

I have the following layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/layout_1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
    android:background="@drawable/1dot6_mb_bitmap">
<include layout="@layout/top_bar"/>
<LinearLayout 
        android:id="@+id/layout_2"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_weight="1"
        android:orientation="vertical">
        <ListView 
            android:id="@+id/layout_3"      
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent">
        </ListVi开发者_Python百科ew>

</LinearLayout> 
<include layout="@layout/bottom_bar"/>

When I set the large bitmap as background for the layout_1 container, the ListView scrolls very slowly. If i remove the image from the background, the ListView scrolls perfectly. I tried also with a ScrollView and it's the same behavior. I cannot use a repeating image or a 9.png because the large image is in fact a landscape photo. Do you any idea how can i solve this issue ? Or what is the reason the ListView/ScrollView behaves so slowly in this case?

Thank you


On the assumption the image is larger than the space it occupies, you can load it into member, using the BitmapFactory class to resize the image before inserting it into the layout.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号