andreea
andreea

Reputation: 3555

Large bitmap under a ListView/ScrollViews slows the scrolling

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">
        </ListView>

</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

Upvotes: 0

Views: 345

Answers (1)

Ollie C
Ollie C

Reputation: 28519

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.

Upvotes: 1

Related Questions