Android 巧妙實現圖片和文字布局


之前寫過一個博客是關於實現圖片和文字左右或者上下布局的方法,

下面是博客的主要內容:

布局文件很簡單,用來展示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來實現這種布局方式,更加有效的實現布局。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM