android Material 按钮无法去除圆角

标签 android material-design android-button material-components-android

我需要删除应用程序中所有按钮的圆角并使用平面背景。最好是一种颜色。
这是我的风格:

<style name="Component.MyTheme.Button" parent="Widget.MaterialComponents.Button.TextButton">
    <item name="android:textColor">@color/white_50</item>
    <item name="backgroundTint">@color/black</item>
    <item name="cornerRadius">@null</item>
</style>
这就是我在我的主题中应用它的方式。
<item name="materialButtonStyle">@style/Component.MyTheme.Button</item>
我想改变这个
enter image description here
对此
enter image description here
编辑:忽略第二张图像两端的白条。

最佳答案

将角半径属性设置为 0dp。

app:cornerRadius="0dp"
就像下面的代码
<com.google.android.material.button.MaterialButton
            android:id="@+id/button_filter_apply"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/apply"
            android:fontFamily="sans-serif"
            android:textAllCaps="true"
            android:textColor="@color/white"
            android:textStyle="bold"
            app:backgroundTint="@color/clear_blue"
            app:cornerRadius="0dp"
            app:layout_constraintBottom_toBottomOf="parent" />
按钮看起来像
enter image description here
编辑:忽略图像两侧的黑条

关于android Material 按钮无法去除圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63317689/

相关文章:

java - 在 Android 中检查 SMS 中的多个关键字

Android EditText MultiLine 可绘制重力

java - 如何检查复选框是否在android应用程序中被选中或未被选中?

css - 尝试创建像文本框这样的 Material 设计,输入验证问题

Android为按钮添加边框而不丢失 Material 主题(使用drawable)

java - 如何根据另一个 View 的位置设置 View 宽度?

android - 使用 Firebase 从列表中查询每个节点的键

android - 在折叠工具栏布局上将 RecyclerView 锚定得更高

angular - 尽管有数据源,但 mat-table angular 6 不显示任何数据

Android Border Less 按钮按下状态背景色