android - 属性 app :cornerRadius doen't work for the MaterialButton

标签 android material-components-android

我正在尝试在屏幕内部布局中使用带有圆角的新 Material Components 实现 MaterialButton

<android.support.design.button.MaterialButton
        android:text="@string/login"
        android:id="@+id/btnEntrance"
        app:layout_constraintStart_toStartOf="parent"
        android:layout_marginStart="104dp"
        style="@style/Widget.MaterialComponents.Button.UnelevatedButton" 
        android:layout_height="40dp"
        app:cornerRadius="8dp"/>

但是在预览屏幕上圆角是不可见的——这个属性不会对 View 产生任何影响。谁能解释一下为什么?

最佳答案

android:theme="@style/Theme.MaterialComponents"

将这条线添加到您的 Material 按钮。

关于android - 属性 app :cornerRadius doen't work for the MaterialButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53270601/

相关文章:

android - 如何使 Android 应用程序数据持久化?

android - 自定义弹出菜单样式

android - 项目的抽屉导航圆角背景

android - 如何在 TextInputLayout 的密码切换按钮上禁用涟漪效应

android - Material design 3 波纹不透明度

java - Moshi + Retrofit - 处理 JSON 响应

android - 在 Android TV 上收听 HDMI 插入和拔出事件

android - 使用 Delphi OpenGL 应用程序在 Android 中显示软键盘(无 FMX)

java - 在 java 中使用正则表达式检查字符串中的特殊字符

android - 将 NavigationView 背景更改为圆形在按下时不起作用