CheckBox和RadioButton设置背景变形

在使用CheckBox 和 RadioButton 的时候一般会有以下需求:

  1. 需要去掉系统带的默认勾选框
    android:button=”@null”

  2. 设置自己需要的背景图片
    android:background=”@drawable/icon_select”

如上设置之后出现背景图片变形,如下图的左边图形看到的那样。
这里写图片描述

这个时候要解决变形的问题,可以设置以下CheckBox和RadioButton的文字大小就可以正常显示。

 <CheckBox
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:button="@null"
       android:background="@drawable/icon_select"
       android:layout_margin="33dp"
       android:textSize="1sp"
       />

猜你喜欢

转载自blog.csdn.net/ysq_chris/article/details/80785401