2012-03-30 52 views
0

我創建了自己的選擇器到複選框,但無法更改它的大小。如果我將layout_height從wrap_content設置爲20dp,行高變小,但複選框的大小保持不變,導致彼此重疊。如果我用layout_height和width設置了android:height =「20dp」和android:width =「20dp」,則沒有任何反應。爲什麼?Android調整大小複選框

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


     <CheckBox 
      android:id="@+id/multiple_checkbox" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_gravity="center_vertical" 
      android:checked="true" 
      android:button="@drawable/productlists_custom_cb" 
      android:clickable="false" 
      android:focusable="false" 
      android:focusableInTouchMode="false" /> 

回答

0

你爲什麼不把

android:layout_width="20dip" 
android:layout_height="20dip" 

只在您的佈局XML。這有效,但不是你喜歡看的方式。 爲什麼你不把你的圖像應用爲複選框,並將其大小調整爲任何你想要的大小。

+0

你的意思是我應該在我創建它們的圖像編輯器中將複選框圖像的大小調整爲較小的值?我做到了,它的工作原理,但我不明白爲什麼我不能在android中調整它們的大小。 – erdomester 2012-03-30 16:06:54