zoukankan      html  css  js  c++  java
  • Android新手之旅(7) RadioButton的自定义

    希望用到RadioGroup的功能,但遇到一些看似简单问题却无法解决:系统的图标太大却难以更换,在网上找解决方案。有些地方提到,由于用的是图片,所以无法缩小,只好自定义,参考1 参考2

    然后,找图标,在sdk文件夹下搜索含radio的文件,很多,选一套合适的即可。

    这是在res/drawable下的radiobutton.xml文件

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item
              android:state_enabled="true"
              android:state_checked="true"
              android:drawable="@drawable/check" />
        <item             
              android:state_enabled="true"    
              android:state_checked="false"
              android:drawable="@drawable/checknull" />
    </selector>

    这是radiogroup的定义。注意:

    1、RadioGroup 方向是水平,android:orientation="horizontal" 。

    2、button的样式是android:button = "@drawable/radiobutton"。为了找这个属性费了大劲了。

    <RadioGroup android:id="@+id/radioGroup1" android:paddingTop="30px" android:paddingLeft="15px" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" >
        <RadioButton android:text="今天" android:layout_width="wrap_content" android:textSize="14px" android:checked="true" android:layout_height="wrap_content" android:editable="false" android:id="@+id/radio0"  android:button = "@drawable/radiobutton" android:paddingLeft="30px" android:layout_marginRight="2px" android:textColor="#000"></RadioButton>
        <RadioButton android:text="昨天" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/radio1" android:textSize="14px" android:button = "@drawable/radiobutton" android:paddingLeft="30px" android:layout_marginRight="2px" android:textColor="#000"></RadioButton>
        <RadioButton android:text="前天" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/radio2" android:textSize="14px"  android:button = "@drawable/radiobutton" android:paddingLeft="30px" android:layout_marginRight="2px" android:textColor="#000"></RadioButton>
    </RadioGroup>

    image

  • 相关阅读:
    Kappa Architecture: A Different Way to Process Data
    Lambda architecture and Kappa architecture
    Questioning the lambda architecure
    Lambda Architecture: Achieving Velocity and Volume with Big Data
    beego 参数配置
    hadoop 3.1.1 安装
    Idea 切换git账号
    IntelliJ IDEA 开发git多模块项目
    打印1到1亿的平方
    IDEA 逆向工程
  • 原文地址:https://www.cnblogs.com/jetz/p/2115223.html
Copyright © 2011-2022 走看看