我想在我的应用程序中实现一个 Switch 小部件,并且该功能运行良好。我对开关的问题是拇指上的关闭文本(“OFF”)。“OFF”大于拇指的大小。我想增加拇指的大小(或减少拇指文本),但出于某种奇怪的原因,我也不能这样做。这是看起来的样子:
开关的特写
截屏
这是 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/gameSettingsContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
tools:context="com.example.vb1115.multchoicequestion.LaunchScreen">
<LinearLayout
android:id="@+id/lessonModeSliderContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<Switch
android:id="@+id/lessonModeToggleSlider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:showText="true"/>
</LinearLayout>
<ImageView
android:id="@+id/lessonModeAnimatedArrow"
android:src="@mipmap/green_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/lessonModeSliderContainer"/>
</RelativeLayout>
我认为代码本身没有问题。我在 Activity 代码中所做的只是找到 Switch 视图来修改 setOnCheckedChangeListener 方法。