如何在复选框中更改按钮的大小

时间:2016-04-15 14:24:59

标签: android button checkbox size

我尝试使用png文件更改Checkbox中的Button,但图像太大而且按钮太大了。

我想将Button的大小更改为20dp。 然后我在CheckBox中设置layout_width和layout_height,但它没有解决问题。

你能告诉我如何改变大小吗?

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

my_check_box.xml

<template is="dom-repeat" items="[[my_array1]]"> 
  <div>[[item]]</div>
  <div>[[getElementFromArray(index, my_array2)]]</div>
</template>

<script>
  Polymer({
    is: 'my-element',
    getElementFromArray: function(index, arr) {
      return arr[index];
    }
  })
</script>

1 个答案:

答案 0 :(得分:0)

您需要为其设置相关的drawable

<CheckBox 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:text="new checkbox" 
android:background="@drawable/my_checkbox_background"
android:button="@drawable/my_checkbox" />

此链接有很好的例子 Custom Checkbox

相关问题