6
我越來越瘋狂,在Android的4自定義開關部件4
首先的開關按鈕,我已經設置選擇爲背景,從繪製的文件夾中選擇兩個不同的PNG文件:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/form_switch_no" android:state_checked="false"/>
<item android:drawable="@drawable/form_switch_ok" android:state_checked="true"/>
<item android:drawable="@drawable/form_switch_no"/>
</selector>
但我不知道他們爲什麼是x-scaled。我想管理這個尺寸,但我試圖改變layout_width/height/weight ...沒有成功。
我也有一個自定義的PNG文件用作開關的拇指。我還需要管理這個拇指的大小,因爲如果我將textOn和textOff屬性設置爲「」,拇指的大小就會變小。此外,我想改變關於背景的拇指填充,因爲它不會出現居中。
這裏是我的交換機XML定義:
<Switch
android:id="@+id/switchUsers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user"
android:textOn=""
android:textOff=""
android:thumb="@drawable/form_switch_slider"
android:track="@drawable/switch_user_selector" />
我曾試圖改變圖像大小,使他們九宮的,但我無法達到我的目標。
任何幫助將不勝感激。謝謝!