Android javastextview: the pitfalls of CompoundDrawable, androidtextview

Source: Internet
Author: User

Android javastextview: the pitfalls of CompoundDrawable, androidtextview

TextView has several attributes: android: drawableXXX, which usually displays an image around the text, but this pitfall is that the text and image may be different.

Even if you set gravity or layout_gravity = center, there is no effect.

Generally, RadioButton is used in the app navigation bar at the bottom. RadioGroup should be a linear layout. The oratation attribute can be horizontally or vertically arranged.

Since it is the bottom navigation bar, the horizontal layout is usually set, and then each RadioButton sets the weight attribute to 1 at the same time, layout_width to match_parent, and then

Setting the button property to @ null or even setting the background property to null or transparent is still ineffective.

  

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>

 

If you see the preceding and code, you can center the content only when the width is set to wrap_content. Try again and set gravity to center. As a result, you are surprised.

  

It is too difficult to set the center text to be left aligned with the middle of the icon.

I removed all the attributes with full confidence, and I was not aligned accidentally?

  

It would be useless to use wrap for a word. When gravity is added, the word is right and left if no word is added.

If you use a linear layout to install an ImageView and TextView compiler, you will also be prompted to use TextView's drawablexx for implementation ....

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.