我在Fragment中使用切换按钮并设置自定义样式以切换按钮。但在三星设备上它显示默认的系统主题。然后我将相同的布局文件移动到Activity。如果我将相同的布局设置为Activity,它工作正常。
<Switch
android:id="@+id/switch_dict_fade_out"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@id/linLayDilogPar2"
android:layout_alignLeft="@id/linLayDilogPar2"
android:layout_alignRight="@id/linLayDilogPar2"
android:layout_marginTop="15dp"
android:layout_marginLeft="20dp"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:text="@string/dictionary_fadeout"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white"
android:thumb="@drawable/switch_bg"
android:track="@drawable/switch_track_bg" />
<item android:drawable="@drawable/off_switch" android:state_enabled="false"/>
<item android:drawable="@drawable/on_switch" android:state_checked="true"/>
<item android:drawable="@drawable/off_switch"/>
<item android:drawable="@drawable/track_switch" android:state_enabled="false"/>
<item android:drawable="@drawable/track_switch"/>
答案 0 :(得分:0)
尝试添加属性:
android:textOff=""
android:textOn=""
android:switchMinWidth="56dp"