【Android】安卓开发实战之自定义EditText输入框形状颜色
2017-02-20 23:51
483 查看
下面来看一下实现方法:
1、先在drawable文件夹下创建一个myedittext.xml文件,文件代码如下:
2、二是在布局文件里调用这个资源:
3、最后来看一下效果
1、先在drawable文件夹下创建一个myedittext.xml文件,文件代码如下:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <!--solid里是背景的填充颜色,transparent是透明--> <solid android:color="@android:color/transparent"/> <!-- corners里的属性,是四个边角拐角的大小 topLeftRadius:左上角 topRightRadius:右上角 bottomRightRadius:右下角 bottomLeftRadius:左下角 --> <corners android:topLeftRadius="100dp" android:topRightRadius="10dp" android:bottomRightRadius="100dp" android:bottomLeftRadius="10dp" /> <!--stroke里是边框的宽度和颜色--> <stroke android:width="1dp" android:color="@android:color/holo_blue_light" /> </shape>
2、二是在布局文件里调用这个资源:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" tools:context="com.example.test.MainActivity"> <!--在background里设置就好--> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/myedittext" /> </RelativeLayout>
3、最后来看一下效果
相关文章推荐
- 【Android】安卓开发实战之自定义对话框位置、大小、颜色、形状
- 【Android】安卓开发实战之自定义ActionBar(活动栏、状态栏)颜色且没有色差
- 【Android】安卓开发实战之自定义分隔线条的长度、宽度、颜色
- Android开发全程记录(十三)——EditText自定义边框颜色
- 【Android】安卓开发实战之Java代码中控制EditText插入图片的大小
- [置顶] android开发之edittext弹出输入框遮挡住文字。解决方法
- Android之EditText自定义边框和边框颜色(转载)
- Android 自定义EditText输入框 带清空按钮
- Android实战简易教程-第三十二枪(自定义View登录注册界面EditText-实现一键清空)
- 【Android】安卓开发实战之自定义仿iPhone导航条组件
- Android 自定义EditText输入框带清空按钮
- Android开发中EditText当被选中后怎么修改下划线和hint值得颜色
- Android开发中EditText小技巧之如何设置光标颜色及粗细
- Android - VGA,ADB,DDMS,安卓开发环境目录结构,安卓目录结构,常见布局,点击事件的几种写法,控件(Button/TextView/ImageView/EditText)
- android开发之edittext弹出输入框遮挡住文字。解决方法
- Android自定义价格输入框EditText
- Android开发总结笔记 EditText(输入框) 1-1-7
- Android实战简易教程<三十二>(自定义View登录注册界面EditText-实现一键清空)
- Android实战简易教程-第七十枪(自定义实用控制之-邮箱验证EditText)
- android EditText自定义开发实例