Eclipse hint: This tag and its children can replaced by one <TextView/> and a compound drawable

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.