我有一個佈局,如下所示。它被代碼誇大了,並被添加到了一個HorizontalScrollView,有時幾百次,並導致內存問題。我的佈局可以提高效率嗎?
我想知道是否有任何可以做到使其更有效?最初我使用了LinearLayouts,用RelativeLayout替換它對滾動有很大的影響。現在我想知道它是否可以進一步改進?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="156dp"
android:layout_height="254dp"
android:paddingLeft="7dip"
android:paddingRight="7dip">
<FrameLayout android:id="@+id/button_frame"
android:layout_width="156dp"
android:layout_height="218dp">
<ImageView android:id="@+id/button_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/image_bg"
/>
<ImageView android:id="@+id/button_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|right"
/>
<TextView android:id="@+id/button_select"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:background="@drawable/btn_selector_bg_selected"
/>
<TextView android:id="@+id/button_selected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:background="@drawable/title_bg_selected"/>
</FrameLayout>
<TextView
android:id="@+id/button_title"
android:layout_width="156dp"
android:layout_height="36dp"
android:textColor="#ffffff"
android:singleLine="true"
android:textSize="13sp"
android:textStyle="bold"
android:gravity="center_vertical|left"
android:ellipsize="end"
android:paddingLeft="30dip"
android:paddingRight="5dip"
android:layout_below="@id/button_frame"
android:background="@drawable/title_bg"/>
</RelativeLayout>
的ImageView的button_image使用AQuery圖像緩存填充,所以我不知道是否有更多我可以做,以提高圖像的處理方式。但任何有關改進的提示都非常感謝。
您是否嘗試過使用[merge](http://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-by.html)? – toadzky
有趣,我不知道合併!除了下面的建議佈局更改之外,我一定會嘗試一下。 – androidneil