效果图如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:orientation="vertical" >
  6. <TextView
  7. android:id="@+id/radiobutton_textview"
  8. android:layout_width="fill_parent"
  9. android:layout_height="50dip"
  10. android:background="@android:drawable/title_bar"
  11. android:gravity="center_vertical"
  12. android:textAppearance="?android:attr/textAppearanceLarge"
  13. android:textSize="18dip"
  14. android:textStyle="bold" />
  15. <RadioGroup
  16. android:id="@+id/group"
  17. android:layout_width="fill_parent"
  18. android:layout_height="wrap_content"
  19. android:orientation="vertical" >
  20. <RadioButton
  21. android:id="@+id/button1"
  22. android:layout_width="fill_parent"
  23. android:layout_height="50dip"
  24. android:button="@null"
  25. android:drawableRight="@android:drawable/btn_radio"
  26. android:paddingLeft="30dip"
  27. android:text="Android新手"
  28. android:textSize="20dip" />
  29. <View
  30. android:layout_width="fill_parent"
  31. android:layout_height="1px"
  32. android:background="?android:attr/listDivider" />
  33. <RadioButton
  34. android:id="@+id/button2"
  35. android:layout_width="fill_parent"
  36. android:layout_height="50dip"
  37. android:button="@null"
  38. android:drawableRight="@android:drawable/btn_radio"
  39. android:paddingLeft="30dip"
  40. android:text="Android高手"
  41. android:textSize="20dip" />
  42. </RadioGroup>
  43. </LinearLayout>
  1. package sdfasdf.sadf;
  2. import android.app.Activity;
  3. import android.os.Bundle;
  4. import android.widget.RadioGroup;
  5. import android.widget.RadioGroup.OnCheckedChangeListener;
  6. import android.widget.TextView;
  7. public class SdfsadfasdfasdffActivity extends Activity {
  8. private TextView textView;
  9. private RadioGroup group;
  10. @Override
  11. public void onCreate(Bundle savedInstanceState) {
  12. super.onCreate(savedInstanceState);
  13. setContentView(R.layout.main);
  14. textView = (TextView) findViewById(R.id.radiobutton_textview);
  15. group = (RadioGroup) findViewById(R.id.group);
  16. // 单选按钮组监听事件
  17. group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  18. @Override
  19. public void onCheckedChanged(RadioGroup group, int checkedId) {
  20. // 根据ID判断选择的按钮
  21. if (checkedId == R.id.button1) {
  22. textView.setText("Android新手");
  23. } else {
  24. textView.setText("Android高手");
  25. }
  26. }
  27. });
  28. }
  29. }

http://blog.csdn.net/furongkang/article/details/7272512

Android设置RadioButton在文字的右边的更多相关文章

  1. Android中如何设置RadioButton在文字的右边,图标在左边

    from:http://blog.csdn.net/sunnyfans/article/details/7901592?utm_source=tuicool&utm_medium=referr ...

  2. android自定义radiobutton样式文字颜色随选中状态而改变

    主要是写一个 color selector 在res/建一个文件夹取名color res/color/color_radiobutton.xml <selector xmlns:android= ...

  3. Android 自定义RadioButton实现

    由于使用小米系统MIUI运行是RadioButton样式跟google Android API自定义的不一样,则我们可以定义任何想要的东东.没有做不到,只有想不到 Android 自定义RadioBu ...

  4. Android中代码设置RadioButton的高端技巧

    不知道怎么起标题,就这样了. 目前主要讲两个方面内容: 代码方式 设置RadioButton的 android:button . android:background 等属性为 @null : 代码方 ...

  5. 【Android初级】使用TypeFace设置TextView的文字字体(附源码)

    在Android里面设置一个TextView的文字颜色和文字大小,都很简单,也是一个常用的基本功能.但很少有设置文字字体的,今天要分享的是通过TypeFace去设置TextView的文字字体,布局里面 ...

  6. 转:android 自定义RadioButton样式

    http://gundumw100.iteye.com/blog/1146527  上面这种3选1的效果如何做呢?用代码写? 其实有更简单的办法,忘了RadioButton有什么特性了吗? 我就用Ra ...

  7. 改变RadioButton的文字位置以及距离

    在默认情况下,RadioButton的 文字位置和文字的距离是不变的,为了可以改变它,我们可以用以下的方法. 1.改变文字的位置 android:button="@null" // ...

  8. Android 自定义RadioButton样式

     上面这种3选1的效果如何做呢?用代码写? 其实有更简单的办法,忘了RadioButton有什么特性了吗? 我就用RadioButton实现了如上效果,其实很简单的. 首先定义一张background ...

  9. Android实现自定义带文字和图片的Button

    Android实现自定义带文字和图片的Button 在Android开发中经常会需要用到带文字和图片的button,下面来讲解一下常用的实现办法. 一.用系统自带的Button实现 最简单的一种办法就 ...

随机推荐

  1. 2016年总结 - Java程序员

    一 . 技术积累 (1)代码规范 1.1.1.通常的模块分布:一般如果你要实现一个web应用,你从后台将数据展示到前端页面,在一个比较大的公司,你少不了跟其他项目有交集(你调用他的接口,他依赖你的接口 ...

  2. linux 与 windows 挖门罗币总结

    比特币之前一直很火,初次了解的时候才2000RMB一枚..看不懂哇,错失良机...当然了,看得懂也不买不起..当时还是穷学生. 最近又一直看到黑客利用linux漏洞挖门罗币获利的新闻,决定好生研究一下 ...

  3. MySQL高可用方案MHA在线切换的步骤及原理

    在日常工作中,会碰到如下的场景,如mysql数据库升级,主服务器硬件升级等,这个时候就需要将写操作切换到另外一台服务器上,那么如何进行在线切换呢?同时,要求切换过程短,对业务的影响比较小. MHA就提 ...

  4. MariaDB 安装与启动 过程记录

    1. 安装之前的准备工作 rpm -qa |grep mysql rpm -qa |grep mariadb 按照查出来的软件包使用  yum remove  全部卸载,当然也可以 yum remov ...

  5. Nginx负载均衡中后端节点服务器健康检查的操作梳理

    正常情况下,nginx做反向代理,如果后端节点服务器宕掉的话,nginx默认是不能把这台realserver踢出upstream负载集群的,所以还会有请求转发到后端的这台realserver上面,这样 ...

  6. PLSQL使用技巧 如何设置默认显示My Objects、记住密码等

    https://www.cnblogs.com/yilinzi/p/7144852.html PL/SQL Developer实现双击table查询 https://blog.csdn.net/zhy ...

  7. Record for Individual Project ( Word frequency program )

    1.  预计时间 ● 对问题总体的理解.规划:10 min ● 设计编写程序:5 h ● 调试: 分模块-40 min; 总体-40min ● 测试(性能分析).改进:1 h 2.  实际用时 ● 对 ...

  8. LINUX内核设计第五周——扒开系统调用的三层皮(下)

  9. <构建之法>13-17

    13章软件测试. 从基本名词到软件测试的分类方法,啃完这15页书,至少对与软件测试的理解程度不是停留在以前的层次(让用户使用,然后提出碰到什么问题) 测试不是那么简单就阐述的完全.测试按测试目的分类可 ...

  10. SQL Server 递归查询上级或下级组织数据(上下级数据通用查询语法)

    查询上级组织数据: WITH OCTE AS ( AS LVL FROM IOV_Users U LEFT JOIN IOV_Organization O ON U.OrgId=O.ID UNION ...