一般来说我们给控件(Button,LinearLayout,ImageView,TextView等)设这背景的时候只需要设置这些控件的android:background即可,

但是在给CheckBox设置背景的时候这样设置就会出现背景图片偏大的问题。

怎么保证给CheckBox设置的背景大小正合适呢?请看如下代码:

 <CheckBox
                        android:id="@+id/orderpay_cb_zhifubao"
                        android:layout_width="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:layout_height="wrap_content"
                        android:button="@drawable/xml_cb" />

我们只需要设置android:button="@drawable/图片的背景id"即可。

这是经过测试的,大家放心使用。

相关文章:

  • 2021-11-17
  • 2021-06-03
  • 2021-10-16
  • 2021-09-11
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
  • 2021-04-15
相关资源
相似解决方案