如何在ToggleButton中设置Text的填充?

时间:2019-05-13 13:14:56

标签: android android-layout android-togglebutton

如果设置了ToggleButton

android:layout_width="wrap_content"在文本周围具有默认填充。我想删除文本周围的所有填充,但我发现可以通过设置android:minWidth="0dp"来实现。现在我可以将padding设置为10dp,但是它将在最后剪切文本。有什么办法可以解决这个问题?

<?xml version="1.0" encoding="utf-8"?>
<ToggleButton
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:minWidth="0dp"
    android:layout_height="26dp"
    android:background="@color/colorTextBlue"
    android:textSize="12sp"
    android:text="TextB"
    android:textOff="@null"
    android:textOn="@null"
    android:button="@null"
    android:paddingStart="10dp"
    android:paddingEnd="10dp"
    android:textColor="@color/toggle_color_selector" />

我将为此按钮使用自定义可绘制背景,但这是预览中该按钮的一些外观:

enter image description here

0 个答案:

没有答案