先记一个下载常用logo的网站
1、添加全边框
在drawable 目录下新建一个drawable资源文件,内容如下
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 主题颜色背景经颜色-->
<!-- <solid android:color="#f00"/>-->
<!-- 连框宽度和颜色值 -->
<stroke
android:width="1dp"
android:color="#000" />
</shape>
效果如下
再到要添加边框的控件中设置background属性,应用这个drawable资源文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_marginTop="10dp"
android:layout_width="300dp"
android:layout_height="30dp"
android:hint="请输入用户名"
android:background="@drawable/border"
/>
</LinearLayout>
</LinearLayout>
这样就添加完了。
2、添加单个或多个的上下左右边框,用layer-list样式
新建一个drawable资源文件,代码如下
来源:CSDN
作者:L15579986117
链接:https://blog.csdn.net/L15579986117/article/details/103635841