自定义样式View(三)--自定义EditText

来源:互联网 发布:消费金融用户数据画像 编辑:程序博客网 时间:2024/05/22 15:04

Android中自带的 EditText 样式比较丑,为了美化 EditText 可使用一下方法。
实现效果如下:

自定义EditText 背景
自定义EditText 背景

1.自定义EditText 圆角矩形背景
2.自定义EditText 背景

欢迎关注微信公众号:程序员Android
公众号ID:ProgramAndroid
获取更多信息

微信公众号:ProgramAndroid
微信公众号:ProgramAndroid

我们不是牛逼的程序员,我们只是程序开发中的垫脚石。
我们不发送红包,我们只是红包的搬运工。

1.自定义EditText 圆角矩形背景

自定义圆角矩形 custom_edittext_background.xml

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle">    <!-- 圆角-->    <corners android:radius="5dp" />    <!--描边-->    <stroke        android:width="1dp"        android:color="@android:color/holo_blue_light" /></shape>

2.自定义EditText 背景

 <EditText        android:layout_width="match_parent"        android:layout_height="45dp"        android:layout_margin="10dp"        android:background="@drawable/custom_edittext_background"        android:gravity="center"        android:hint="自定义EditText"        android:paddingLeft="10dp"        android:textSize="16sp" />

至此,自定义圆角矩形输入框已经实现。

​欢迎关注微信公众号:程序员Android
公众号ID:ProgramAndroid
获取更多信息

微信公众号:ProgramAndroid
微信公众号:ProgramAndroid

我们不是牛逼的程序员,我们只是程序开发中的垫脚石。
我们不发送红包,我们只是红包的搬运工。


点击阅读原文,获取更多福利




原创粉丝点击