andriod studio按钮设置不要边框和背景,只要下划线
时间: 2024-02-07 15:03:30 浏览: 92
要设置 Android Studio 中的按钮没有边框和背景,只要下划线,您可以使用以下方法:
1. 在 res/drawable 目录下创建一个名为 "underline.xml" 的新的 XML 文件,并添加以下代码:
```xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="0dp" android:color="@android:color/transparent" />
<padding android:bottom="3dp" />
<solid android:color="@android:color/transparent" />
</shape>
```
2. 在您的布局文件中,添加一个 Button 元素,并将其样式设置为 "underline"。例如:
```xml
<Button
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:textColor="@android:color/holo_blue_dark"
android:textStyle="bold"
android:background="@drawable/underline" />
```
3. 这样,您的按钮将没有边框和背景,只有下划线。
需要注意的是,您还可以在此基础上进行更改和自定义,如更改下划线的颜色、粗细、位置等。
阅读全文
相关推荐














