Android 利用Sharp样式设置文本框EditText圆角形状
1.首先新建样式文件editsharp.xml:
1 <?xml version="1.0" encoding="utf-8"?>
2 <shape xmlns:android="http://schemas.android.com/apk/res/android"
3 android:shape="rectangle" >
4
5 <!-- <gradient
6 android:angle="45"
7 android:endColor="#CCCCCC"
8 android:startColor="#CCCCCC" /> -->
9
10 <padding
11 android:bottom="7dp"
12 android:left="7dp"
13 android:right="7dp"
14 android:top="7dp" />
15 <!-- 设置圆角矩形 -->
16 <corners android:radius="3dp" />
17
18 <stroke
19 android:width="5px"
20 android:color="#1199EF" />
21
22 <solid android:color="#CCCCCC" />
23
24 </shape>
2.在布局文件中引用样式文件:
1 2 3 4 5 | <EditText android:layout_width= "200dp" android:layout_height= "wrap_content" android:layout_marginTop= "20dp" android:background= "@drawable/editsharp" /> |
3.文本框效果图如下:
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步