Today, while learning about Android development, I wrote a code like this:
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"android:gravity= "Center" > <ImageViewAndroid:id= "@+id/imageview2"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" /> <TextViewAndroid:id= "@+id/textview2"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:gravity= "Center" /></LinearLayout>
Eclipse then reports a hint: this tag and its children can replaced by one <TextView/> and a compound drawable
Finally, we looked at the information found:
Sometimes we may use the Image+textview combination, but in fact the image is not necessary, TextView provides a property to set the image
such as: Through the Setcompounddrawable method, or directly in the XML using Android:drawableleft., Android:drawableright, and other properties specified!
Other:
- Set android:baselinealigned= "False" on the This element for better performance
- If LinearLayout is used for nested layout space calculations, its Android:baselinealigned property should be set to false to speed up the layout calculation
- Android:baselinealigned= "false"
- This linearlayout layout or its relativelayout the parent is useless;
- Extra LinearLayout or Relativelayout.
- Delete and then
- Use a layout_height of 0dip instead of wrap_content for better performance
- When you set the weight property for a control in a linearlayout layout, the component fills the remaining space by default
- Remove the weight attribute or modify the wrap_content to 0DP
- Buttons in button bars should is borderless
- Unknown cause
- Style= "? Android:attr/buttonbarbuttonstyle"
Data excerpt: Http://www.tuicool.com/articles/YvMjEz
http://blog.csdn.net/feng88724/article/details/7638511
Eclipse Tip: This tag and its children can replaced by one <TextView/> and a compound drawable