2016-08-02 35 views
2

發現很多有關如何更改的問題/答案。1.複選框顏色,複選框鑽孔顏色等,但不是關於增加複選框邊框(正方形邊框)。如何增加複選框邊框,而不使用android中的圖像

下面

<CheckBox 
     android:id="@+id/mChkAgree" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_margin="10dp" 
     android:buttonTint="@color/black" 
     android:scaleX="1.70" 
     android:scaleY="1.70" 
     android:text="@string/agree_text" 
     android:textColor="@color/black" 
     android:textSize="14sp" /> 

我複選框XML代碼現在複選框邊框幾乎看不到

enter image description here

因此,如何提高方形複選框的邊框(寬度)?

另外我不想使用圖像複選框,所以它可能不使用自定義圖像?

回答

0

這個職位根據:http://www.techrepublic.com/blog/software-engineer/create-a-custom-checkbox-in-your-android-app/

增加正方形邊框的最佳方法是使用帶有定製的Android複選框:繪製標籤。自定義繪製的

例(投入/ RES/XML文件夾)

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
<stroke android:width="4px"/> 
<size android:height="20dp" android:width="20dp"/> 
</shape> 

而且......

<CheckBox 
    android:id="@+id/mChkAgree" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_margin="10dp" 
    android:buttonTint="@color/black" 
    android:scaleX="1.70" 
    android:scaleY="1.70" 
    android:text="@string/agree_text" 
    android:textColor="@color/black" 
    android:textSize="14sp" 
    android:drawable="@xml/custom_checkbox /> 
+1

非常感謝,但你的解決方案,並在該職位別解工作。您的解決方案無效,而該鏈接中的解決方案則爲廣場填充黑色 –