如何在android中增加开关部件的拇指大小?
问题描述:
我正在使用开关小部件。这里是代码如何在android中增加开关部件的拇指大小?
<Switch
android:id="@+id/switchFabric"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:showText="true"
android:switchTextAppearance="@style/SwitchTextAppearance"
android:text="Do you have fabric ?"
android:textColor="@color/black_overlay"
android:textOff="No"
android:textOn="Yes"
android:thumbTextPadding="@dimen/padding_4"
android:padding="@dimen/padding_8"
android:thumbTint="@color/white"
android:layout_marginTop="@dimen/margin_10"
android:layout_marginBottom="@dimen/margin_20"
/>
它出来是这个
我想增加拇指的大小,以便有文字周围有足够的填充。我曾尝试与
thumbPadding
填充试验
switchMinWidth
如何实现这一目标? 任何建议表示赞赏。提前致谢。
答
试试这个创建主题类似这样的
<style name="MySwitchStyle">
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">15sp</item>
</style>
比适用于交换机
<Switch
android:id="@+id/switchFabric"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:showText="true"
android:switchTextAppearance="@style/SwitchTextAppearance"
android:text="Do you have fabric ?"
android:textColor="@color/black_overlay"
android:textOff="No"
android:textOn="Yes"
android:scaleX="2"
android:scaleY="2"
android:thumbTextPadding="@dimen/padding_4"
android:padding="@dimen/padding_8"
android:thumbTint="@color/white"
app:switchTextAppearance="@style/MySwitchStyle"
android:layout_marginTop="@dimen/margin_10"
android:layout_marginBottom="@dimen/margin_20"
/>
答
我想这应该做它为我工作
<android.support.v7.widget.SwitchCompat
android:id="@+id/switch_compat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:checked="true"
android:scaleX="2"
android:scaleY="2"
android:textOn="YES"
android:textOff="NO"
app:switchTextAppearance="@style/dd"
app:showText="true" />
添加作业以下行在你的styles.xml中
<style name="dd">
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">10sp</item>
</style>
根据需要调整文本大小和缩放大小
没有抱歉,它没有帮助。它只是增加了文本的大小。 –
结帐我编辑的答案 –