gpt4 book ai didi

android - 如何删除 Material 设计按钮中的额外填充或边距?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:53:55 24 4
gpt4 key购买 nike

我正在尝试创建一个按钮,它附加到按钮上方的 TextView,如下图所示。

enter image description here

以上截图来自Note 4,操作系统版本为5.0.1。

下面是实现UI的代码。

布局/xyz.xml

    <Button
android:layout_width="250dp"
android:layout_height="50dp"
android:theme="@style/myButton"
android:text="Cancel"/>

values-v21/style.xml

    <style name="myButton" parent="@style/Base.Widget.AppCompat.Button">
<item name="android:colorButtonNormal">#3578A9</item>
<item name="android:inset">0dp</item>
</style>

但如果我在 Nexus4 操作系统版本 5.1.1 中运行相同的代码,该按钮会占用所有 4 个边的边距,屏幕截图如下所示。

enter image description here

如果我删除“android:theme”并提供“android:background”,UI 看起来就像第一张图片。但它不会产生链式 react 。那么如何将 UI 实现为具有涟漪效果的第一张图片。

最佳答案

android:insetBottom="0dp"

<com.google.android.material.button.MaterialButton
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="56dp"
android:text="Edit"
app:cornerRadius="0dp"
android:insetBottom="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

关于android - 如何删除 Material 设计按钮中的额外填充或边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34989961/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com