Android EditText设置边框
Android EditText设置边框
简介
Android应用程序中给EditText设置边框。
效果图:
快速开始
- 在res/drawable目录下新建样式文件 edit_background.xml。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item><shapeandroid:shape="rectangle"><solid android:color="#efefef"/><corners android:radius="5dp"/><strokeandroid:width="1dp"android:color="#505050"/></shape></item>
- 布局文件中使用边框效果,/res/layout/activity_edit_text.xml。
android:background="@drawable/edit_background"
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"tools:context=".EditTextActivity"><TextViewandroid:id="@+id/name_label"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="账号:"android:textSize="18sp"android:textColor="#353535"android:layout_marginTop="60dp"android:layout_marginStart="60dp"app:layout_constraintTop_toTopOf="parent"app:layout_constraintLeft_toLeftOf="parent"/><EditTextandroid:id="@+id/edit_name"android:layout_width="200dp"android:layout_height="40dp"android:hint="请输入账号"android:gravity="center"android:inputType="number"android:background="@drawable/edit_background"android:layout_marginStart="10dp"app:layout_constraintTop_toTopOf="@id/name_label"app:layout_constraintBottom_toBottomOf="@id/name_label"app:layout_constraintLeft_toRightOf="@id/name_label"/><TextViewandroid:id="@+id/pwd_label"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="密码:"android:textSize="18sp"android:textColor="#353535"android:layout_marginTop="40dp"android:layout_marginStart="60dp"app:layout_constraintTop_toBottomOf="@id/name_label"app:layout_constraintLeft_toLeftOf="parent"/><EditTextandroid:id="@+id/edit_pwd"android:layout_width="200dp"android:layout_height="40dp"android:hint="请输入密码"android:gravity="center"android:inputType="textPassword"android:background="@drawable/edit_background"android:layout_marginStart="10dp"app:layout_constraintTop_toTopOf="@id/pwd_label"app:layout_constraintBottom_toBottomOf="@id/pwd_label"app:layout_constraintLeft_toRightOf="@id/pwd_label"/><Buttonandroid:id="@+id/btn_login"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="ok"android:layout_marginTop="30dp"android:layout_marginStart="110dp"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintTop_toBottomOf="@id/pwd_label"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Cancel"android:layout_marginStart="50dp"app:layout_constraintTop_toTopOf="@id/btn_login"app:layout_constraintLeft_toRightOf="@id/btn_login"/></android.support.constraint.ConstraintLayout>
Android EditText设置边框相关推荐
- Android EditText设置弹出数字输入法键盘
Android EditText 设置弹出数字输入法键盘 首先设置只能输入数字: <EditText Android:id="@+id/edit_digit_input" a ...
- maxlength不起作用android,Android EditText设置Filter以后(xml布局文件中maxLength不起作用的解决办法)...
Android EditText设置Filter以后,xml布局文件中maxLength不起作用的解决办法 问题发现 最近项目里有个需求,文本框禁用emoji表情的输入,因为用到的地方较多,第一个想到 ...
- android edittext圆角边框,Android中使用shape实现EditText圆角
之前看到手机上的百度editText控件是圆角的就尝试做了一下,看了看相关的文章. 因为代码少,看看就知道了.所以下面我就直接贴上代码供大家参考,有其他的好方法记得分享哦~ 整个代码不涉及JAVA代码 ...
- Android ImageView设置边框
ImageView设置边框其实很简单,一个shape就能搞定,无需自定义image view. shape_gray_square_bg.xml <?xml version="1.0& ...
- android imageview设置边框,android ImageView 添加边框
有两种方法可以给ImageView添加边框,一种是通过xml文件配置shape.另一种是重写ImageView的ondraw方法,这里用第二中方法: package org.example.image ...
- android edittext圆角边框,andriod中设置EditText的圆角弧度
不知不觉,已经上班了好几天了,为了让我可以更好的记忆我学的知识,也为了方便我自己查找资料,所以决定将它写出来,和大家分享. 安卓自带的EditText控件,在不同的手机中显示的格式有很大的差别,有的只 ...
- android edittext设置内容为空,android – 我将EditText的InputType设置为TYPE_NULL后无法更改...
我将EditText的InputType设置为TYPE_NULL: editText.setInputType(InputType.TYPE_NULL); 我可以将它设置为TYPE_NULL,它有效! ...
- android EditText 设置弹出数字输入法键盘
首先设置只能输入数字: <EditText android:id="@+id/edit_digit_input" android:layout_width="wra ...
- (转)android EditText 设置弹出数字输入法键盘
首先设置只能输入数字: [html] view plaincopy <EditText android:id="@+id/edit_digit_input" android: ...
最新文章
- 如何重装计算机操作系统,自己如何重装笔记本电脑操作系统呢?
- ASP.NET MVC 5 - 视图
- sublime使用总结
- Android 通过 XMPP 实现聊天功能,App Engine Assisted Group Chat (开源)
- 一文了解YOLO-v4目标检测
- excel多元线性拟合_Python一元线性回归分析实例:价格与需求的相关性
- EasyVS 0.3版本发布 -- 给力变换vs编辑器主题
- facenet训练自己的数据_①如何帮助自己简易分析体测数据②没有私教一个人无法开始训练?...
- 计算机算法设计与分析 旅行售货员问题
- 在工作流引擎基础上搭建电子商务揽收系统解决方案
- Android开源框架Universal-Image-Loader完全解析(三)
- TI 16位 3.3V--5V 电平转换芯片 SN74ALVC164245
- python对象数组排序_如何在JavaScript中对对象数组进行排序
- 敏捷开发项目人力工时评估法则
- Redis分布式缓存学习总结1(安装)
- 用C语言实现贪吃蛇笔记1-------.wav格式音乐的添加及播放(方法一:嵌入到可执行文件里面)
- python把一堆图片分成n份_用Python实现将一张图片分成9宫格的示例
- 乔布斯去世1年后,我说点什么?
- solidworks出现操作系统当前的配置不能运行此应用程序
- 因果推断综述-基础知识2
热门文章
- 前后端交互,密码加密,RSA 实现前端 js 加密,后端 go 解密
- 数据结构-第一讲 基本概念-学习笔记(MOOC 浙江大学 陈越 何钦铭)
- 哈佛国际评论学术写作挑战赛介绍
- 后台启动elastisearch-head,避免后台启动es head在关闭shell后es head自动关闭,网上一大堆错误的,这个是正解,来自互联网
- python中对字符串进行左、中、右对齐操作
- Java8 JVM运行时数据区概述 (极其详细长文)
- MUSCI算法估计空间方位角
- Ruby+Appium demo
- 苹果计算机快捷键设置,那些你必须熟悉苹果电脑的快捷键,你知道吗?
- spark:Task,Partition,RDD、节点数、Executor数、core数目的关系和Application,Driver,Job,Task,Stage理解