android - 改变按钮的高度

标签 android android-layout

我正在尝试更改应用中几个按钮的高度。

my app screenshot

我尝试将 @android:color/transparent 设置为 android:background 并且我还尝试将 layout_height 设置为类似的值16dp

我怎样才能让我的按钮的高度更小?

这是样式 xml:

<style name="Theme.PMBAppTheme.TextButton">
    <item name="android:textStyle">bold</item>
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@drawable/text_button_text</item>
    <item name="android:background">#ff3300</item>
    <item name="android:padding">0dp</item>
    <item name="android:height">20sp</item>
</style>

布局:

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/register_btn_privacy"
        android:text="@string/privacy_policy" 
        style="@style/Theme.PMBAppTheme.TextButton"
        />

text_button_text:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_focused="true" android:state_pressed="true" android:color="@color/muted_pink_over" />
    <item android:state_focused="false" android:state_pressed="true" android:color="@color/muted_pink_over" /> 
    <item android:color="@color/muted_pink" /> 
</selector>

最佳答案

设置按钮的高度为wrap_content:

android:layout_height="wrap_content"

这应该将按钮的高度设置为最小值以显示其文本。

关于android - 改变按钮的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15073344/

相关文章:

android - 通过 xml 中的 <fragment> 标签或通过代码中的 FragmentManager 将 fragment 添加到 Activity 中哪个更好?

android - ListView 在 android 中使应用程序崩溃

android - 在 Canvas 上动画绘制圆/弧

java - ClassCastException : Fragment cannot be cast to Fragment

android - 在运行时使用 MVVM 中的数据添加绑定(bind) View

android-studio - Android 3.3 和 ConstraintLayout 问题

android - 横向模式 - Android

php - 如何在 mysql 中使用 firebase token ?

javascript - 我可以用 javascript/HTML/CSS 编写一个应用程序并在应用商店、google 的 play 和 microsoft 移动应用商店出售吗?

android - 为什么 setText() 在 TextView 的以下代码中不起作用?