Androidのtextview's compounddrawable those pits

Source: Internet
Author: User

TextView has several property android:drawablexxx, usually displaying an image around the surrounding text, but there is a hole in it where text and pictures may be misaligned.

Even if you set gravity or Layout_gravity=center, it has no effect.

Generally in the bottom of the app navigation bar, will use RadioButton to achieve. Radiogroup should be a linear layout that supports oratation properties that can be arranged horizontally or vertically.

Since it is the bottom navigation bar, generally set the landscape layout, and then each RadioButton the weight property is set to 1,layout_width set to Match_parent, and then

Setting the Button property to @null, or even setting the background property to empty or transparent, has no effect.

  

The code:

  

<linearlayout        android:layout_width= "match_parent"        android:layout_height= "Wrap_content"        Android : orientation= "Horizontal" >        <textview            android:layout_width= "wrap_content"            android:layout_ height= "Wrap_content"            android:drawabletop= "? Android:attr/listchoiceindicatorsingle"            android:text= "@ String/hello_world "/>        <textview            android:layout_width=" 0DP "            android:layout_height=" Wrap_ Content "            android:layout_weight=" 1 "            android:drawabletop="? Android:attr/listchoiceindicatorsingle "            android:text= "@string/hello_world"/>        <textview            android:layout_width= "100DP"            Android : layout_height= "wrap_content"            android:drawabletop= "? Android:attr/listchoiceindicatorsingle"            android: text= "@string/hello_world"/>    </LinearLayout>

See the above and the code, only the width is set to Wrap_content to center. Try to set gravity to center, and you'll be surprised.

  

Setting the center text is also left-aligned with the middle of the icon, too much pit.

I took all the attributes out of my confidence, and then I accidentally did not align them?

  

If it is a word with wrap unexpectedly also useless, add gravity this my word to the right point, do not add on the left point.

If you use a linear layout to install a imageview and TextView compiler also prompts you to use the TextView Drawablexx to implement ....

Androidのtextview's compounddrawable those pits

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.