Android 自定义按钮未完全显示
我试图设置一个可绘制的按钮作为背景,但现在只是圆角 以下是可绘制的代码:Android 自定义按钮未完全显示,android,android-layout,android-drawable,android-button,material-components-android,Android,Android Layout,Android Drawable,Android Button,Material Components Android,我试图设置一个可绘制的按钮作为背景,但现在只是圆角 以下是可绘制的代码: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:r
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="1000dp"/>
<solid android:color="@color/light_notlight_themebased_accentColor" />
<padding
android:bottom="7dp"
android:top="7dp"
android:left="7dp"
android:right="7dp" />
<stroke
android:color="@color/ContrastAndText"
android:width="10dp" />
</shape>
下面是按钮的代码:
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/login_loginbutton_default"
android:text="@string/login_loginButton"
android:textAllCaps="true"
android:textColor="@color/NavbarAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent" />
笔划和颜色不显示(它保持背景色),只圆角
下面是它的外观:
在AndroidStudio预览(金丝雀4.1)中:
设备上的最终结果:
什么是我的错?提前谢谢 如果您使用的是MaterialComponents主题,则
和
之间没有区别。检查这个答案是否正确
如果要在按钮中使用android:background
属性,必须使用1.2.0-alpha06
或更高版本
<MaterialButton
app:backgroundTint="@null"
android:background="@drawable/button_gradient"
... />
您正在使用材质组件库吗?使用哪个版本?是的。实现'com.google.android.material:material:1.1.0'谢谢,我现在刚刚使用了AppCompat按钮,它工作得非常好:)
<com.google.android.material.button.MaterialButton
app:cornerRadius="@dimen/..."
app:strokeColor="@color/.."
app:strokeWidth="@dimen/.."
..>