首页 > 系统 > Android > 正文

Android代码实现图片和文字上下布局

2019-10-24 20:34:19
字体:
来源:转载
供稿:网友

在Android开发中经常会需要用到带文字和图片的button,下面来给大家介绍使用radiobutton实现图片和文字上下布局或左右布局。感兴趣的朋友一起学习吧

在Android开发中经常会需要用到带文字和图片的button,下面来给大家介绍使用radiobutton实现图片和文字上下布局或左右布局。代码很简单就不给大家多解释了。

布局文件很简单,用来展示RadioBUtton的使用方法。

 

 
  1. <?xml version="." encoding="utf-"?> 
  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. <RadioButton 
  7. android:layout_width="wrap_content" 
  8. android:layout_height="wrap_content" 
  9. android:layout_centerInParent="true" 
  10. android:button="@null" 
  11. android:drawableTop="@drawable/ic_launcher" 
  12. android:text="Test Button" /> 
  13. </RelativeLayout> 

效果图如下

Android代码实现图片和文字上下布局

以上代码我没有写注释,相信大家都可以看懂吧,关于以上代码有任何问题欢迎给我留言,我会在第一时间和大家联系的。谢谢大家。


注:相关教程知识阅读请移步到Android开发频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表