之前寫過一個博客是關於實現圖片和文字左右或者上下布局的方法,
下面是博客的主要內容:
布局文件很簡單,用來展示RadioButton的使用方法。
1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 7 <RadioButton 8 android:layout_width="wrap_content" 9 android:layout_height="wrap_content" 10 android:layout_centerInParent="true" 11 android:button="@null" 12 android:drawableTop="@drawable/ic_launcher" 13 android:text="Test Button" /> 14 15 </RelativeLayout>
效果圖如下
今天偶然的時候發現不只是RadioButton有
android:drawableTop這個屬性,好多的控件都有這個屬性,像TextView、ChexkBox等等,而且還可以通過設置drawablepadding來設置圖片和文字的距離。
這樣就可以省的寫LinearLayout或者RelativeLayout來實現這種布局方式,更加有效的實現布局。