1、现在res/drawable目录下见mystyle.xml文件,内容如下:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@color/green" />
<item android:state_checked="true"
android:drawable="@color/qianhuise" />
</selector>

2、在控件中引用:android:background="@drawable/mainstyle"

<RadioButton
android:id="@+id/second"

style="@style/main_style "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/group_add_checkbox_select"
android:background="@drawable/mainstyle"
android:text="第二个" />

3、颜色xml定义如下:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="qianhuise">#F0F0F0</color>
<color name="red">#fd8d8d</color>
<color name="green">#9cfda3</color>
<color name="blue">#8d9dfd</color>
<color name="white">#FFFFFF</color>
<color name="orange">#f37301</color>
<color name="black">#000000</color>
<color name="gray">#050505</color>
<color name="listDivider">#ffcc99</color>
</resources>

更多相关文章

  1. android 改变线程优先级Change Thread Priority
  2. not using the 2- or 3-argument View constructors
  3. 【PullToRefresh 系列一基本使用方法】 Android上拉加载下拉刷新
  4. Android使用Handler实现倒计时功能
  5. TimePicker点击上下方向键 java.lang.NullPointerException异常
  6. android Dialog 各种Dialog 三个选项的、进度条的、单选的、多选
  7. android 自定义信息提示框
  8. 用户界面View之ProgressBar
  9. android 动态添加控件并实现每个子控件的点击事件

随机推荐

  1. android 图形展示
  2. Android自定义Toast的时长、位置、及显示
  3. SlidingDrawer源码分析
  4. Android布局优化之Include(一)
  5. Android画图之Matrix(二)
  6. Android中socket(tcp|udp),websocket基本
  7. Android(安卓)Camera数据流分析全程记录
  8. Accessibility辅助功能--一念天堂,一念地
  9. AsyncTask研究(以Android(安卓)10.0为准)
  10. android frida 检测_Android逆向之hook框