Android 巧妙實現圖片和文字上下布局或者左右布局


最近去了一家新公司,然后開始做新的項目,看其代碼發現了一個很巧妙的方法來實現圖片在上面文字在下面的布局方式。只需要一個控件——RadioButton。

布局文件很簡單,用來展示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>

效果圖如下

簡直就是Perfect啊。


免責聲明!

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



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