androidlayoutlayout-optimization

Meaning of layoutopt tool output


I use layoutopt like 'layoutopt layout.xml'

And I get this message:

9:18 This tag and its children can be replaced by one <TextView/> and a compound drawable
28:78 Use an android:layout_height of 0dip instead of wrap_content for better performance

But I do not understand the meaning, can someone clarify me the meaning of it

use 0dip on what? on the layout? I want my layout to wrap the content not to be zero size height

<LinearLayout android:id="@+id/linearLayout3"
   android:layout_width="fill_parent" android:layout_height="0px"
   android:layout_alignParentTop="true" android:background="#30000000"
   android:padding="5dip">

   <ImageView android:id="@+id/imageView1"
      android:layout_width="wrap_content" android:layout_height="wrap_content"
      android:background="@drawable/bzz_icon"></ImageView>

   <TextView android:layout_width="fill_parent" android:id="@+id/textView1"
      android:textColor="#FFFFFF" android:layout_height="wrap_content"
      android:layout_gravity="center" android:gravity="left"
      android:layout_marginLeft="15dip" android:text="@string/title"
      android:textSize="20sp"></TextView>

</LinearLayout>

Solution

  • The first message is saying that you can replace your linearLayout3 with only a TextView and use android:drawableLeft instead of the ImageView.

    The second message is probably telling you that on whatever is at line 28 of your layout you can use layout_height of 0dp instead of wrap_content. This is usually used in conjunction with layout_weight when your element will be expanded anyway. However, this is just a guess and you should post your entire layout XML, including line 28, so that we can better figure out the meaning of the message.