不知不觉,已经上班了好几天了,为了让我可以更好的记忆我学的知识,也为了方便我自己查找资料,所以决定将它写出来,和大家分享。
安卓自带的EditText控件,在不同的手机中显示的格式有很大的差别,有的只是一条横线,有的是矩形框,为了统一格式,我们通常需要对其进行一些简单的操作,下面我介绍一种将其设置为圆角框的方式。
首先需要在drawable中新建一个round_editstyle的xml文件:
zx
?xml version="1.0" encoding="utf-8"?>
<!-- 设置圆角边框 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="#ff0122" />
<corners
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"
android:topLeftRadius="30dp"
android:topRightRadius="30dp" />
</shape>
圆角的弧度可以自己调,我设置它为30度。之后我们就可以在布局文件中直接在background标签中引用它了:
<EditText
android:layout_marginTop="100dp"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:hint="EditTextDemo"
android:gravity="center"
android:background="@drawable/rounder_editstyle" />
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。