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 ....