Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollview is extremly slow on ics (android 4.0) when containing a long textview

Here's my problem, i'm developing a news applicaiton and i used scrollview wrapping a textview to show the content of the news. But i found that scrolling is extremly slow on android 4.0 ics when the textview is quite long, and the longer the text, the slower the scrolling is. While on android 2.3 devices things just go as fast as expected.

I don't know whether this is really a system bug cause i found this similar problems reported on the android project

Here's my layout:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:id="@id/lst_news_details"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/list_background"
        android:fadingEdge="none"
        android:gravity="center" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginTop="10dp"
                android:orientation="vertical" >

                <TextView
                    android:id="@id/tv_news_details_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="@style/Detail_Title"/>

                <TextView
                    android:id="@id/tv_news_details_category"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="@style/Detail_Category"/>

                <TextView
                    android:id="@id/tv_news_details_created_at"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="10dp"
                    style="@style/Detail_Time"/>

                <include layout="@layout/detail_horizontal_divideline" />

                <ImageView
                    android:id="@id/img_news_details_image"
                    style="@style/Detail_Picture"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    android:layout_gravity="center_horizontal"
                    android:contentDescription="@string/image_contentDescription"/>

                <TextView
                    android:id="@id/tv_news_details_context"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:layout_gravity="center_horizontal"
                    style="@style/Detail_Content"/>

            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="10dip" />

        </LinearLayout>

    </ScrollView>

     <!-- actionbar shadow -->
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/action_bar_shadow"
        >
    </LinearLayout>

</FrameLayout>

And my style.xml

<style name="Detail_Title">
     <item name="android:textColor">@color/list_item_title</item>
     <item name="android:textSize">18sp</item>
     <item name="android:shadowColor">@color/list_item_text_shadow</item>
     <item name="android:shadowDx">0</item>
     <item name="android:shadowDy">2</item>
     <item name="android:shadowRadius">2</item>
 </style>

 <style name="Detail_Category">
     <item name="android:textColor">@color/list_item_category</item>
     <item name="android:textSize">14sp</item>
     <item name="android:shadowColor">@color/list_item_text_shadow</item>
     <item name="android:shadowDx">0</item>
     <item name="android:shadowDy">2</item>
     <item name="android:shadowRadius">2</item>
 </style>

 <style name="Detail_Time">
     <item name="android:textColor">@color/list_item_time</item>
     <item name="android:textSize">14sp</item>
     <item name="android:shadowColor">@color/list_item_text_shadow</item>
     <item name="android:shadowDx">0</item>
     <item name="android:shadowDy">2</item>
     <item name="android:shadowRadius">2</item>
 </style>

 <style name="Detail_Content">
     <item name="android:textColor">@color/detail_content_text</item>
     <item name="android:textSize">16sp</item>
     <item name="android:autoLink">all</item>
     <item name="android:shadowColor">@color/list_item_text_shadow</item>
     <item name="android:shadowDx">0</item>
     <item name="android:shadowDy">2</item>
     <item name="android:shadowRadius">2</item>
 </style>

 <style name="Detail_Picture">
    <item name="android:layout_gravity">center</item>
    <item name="android:gravity">center</item>
    <item name="android:background">@drawable/image_frame</item>
 </style>

By the way, i've already set

android:minSdkVersion="7" android:targetSdkVersion="14"

But haven't set the hardware accelerated flag yet.

Is there any solution? Please help me, thanks!

like image 587
dark_chenshifei Avatar asked Dec 09 '22 21:12

dark_chenshifei


1 Answers

Well, i've found the solution on my own

just set android:hardwareAccelerated="false" in the manifest.xml

Still quite confused about the reason, waiting for an explanation.

like image 121
dark_chenshifei Avatar answered Feb 09 '23 01:02

dark_chenshifei