java按钮边框不显示
我尝试在安卓中为按钮添加边框,但不幸的是,我看不到按钮边框
可拉伸锉刀👇
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:安卓="http://schemas.安卓.com/apk/res/安卓">
<item>
<shape 安卓:shape="rectangle">
<corners 安卓:radius="12dp" />
<stroke 安卓:width="3px" 安卓:color="#7E8082" />
</shape>
</item>
</selector>
XML👇
<Button
安卓:id="@+id/btn_signup"
安卓:layout_width="match_parent"
安卓:layout_height="60dp"
安卓:layout_marginTop="122dp"
安卓:background="@drawable/bg_signup"
安卓:fontFamily="@font/poppins_semibold"
安卓:text="Create an Account"
安卓:textAllCaps="false"
安卓:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@+id/btn_login" />
# 1 楼答案
使用Style属性而不是
android:background="@drawable/bg_signup"
制作一个自定义样式,然后将其命名为
android:style="@style/bg_signup"
# 2 楼答案
您不需要使用定制的绘图工具,只需使用
MaterialButton
:# 3 楼答案
不要对单个选项使用选择器直接使用
shape
bg_注册