Android - 从按钮中删除填充

标签 android

如何从 Button View 中删除填充? 无论如何,至少我需要在所有边上都有相等的填充。

我有这个

<Button
   style="@style/btnStart"
   android:text="@string/start" />

还有这种风格

<style name="btnStart" parent="@android:style/Widget.Button">
    <item name="android:background">@drawable/selector_start_button</item>
    <item name="android:textColor">@drawable/selector_start_button_text</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textSize">24sp</item>                       
</style>

还有这个可绘制的 selector_start_button.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
    <shape>
        <solid android:color="@color/start_button" />
        <stroke android:color="@color/start_button" android:width="1dp" />
        <padding
        android:left="0dp"
        android:top="0dp"
        android:right="0dp"
        android:bottom="0dp" />            
    </shape>            
    </item>

    <item>
        <shape>
            <solid android:color="#00000000" />
            <stroke android:color="@color/start_button" android:width="1dp" />            
            <padding
            android:left="0dp"
            android:top="0dp"
            android:right="0dp"
            android:bottom="0dp" />
        </shape>
    </item>
</selector>

但我还是明白了

button with unwanted padding

最佳答案

也许您的按钮继承了一个 minHeight。尝试覆盖它:

<Button
    ...
    android:minHeight="0dp"
    .../>

关于Android - 从按钮中删除填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20179302/

相关文章:

java - 如何使用 Android Sdk 在 aws S3 存储桶中创建空文件夹?

安卓权限 : App crashes needing bluetooth permission

android - 如果我使用 passwordToggleEnabled (EditText),我的 drawableLeft 就会消失

android - apk2bar 生成包的 Blackberry package-id

android - 可以使用 RecyclerView Firebase UI 进行无限滚动吗?

android - 在 GradientDrawable Android 上设置描边

android - SQLite Where IN 后跟变量 String

java - 使用 setDisplayHomeAsUpEnabled 返回 list 中的 PARENT_ACTIVITY 时出现问题

android - 可以在应用程序中查看 jQuery/Javascript 吗?

android - ACS 向 Android 设备推送通知失败,状态为 "Failed (2)"