Android开发学习日记---编辑框EditText边框样式设计

一、效果展示

 二、实现步骤

  首先默认边框什么也不用改,无边框是通过在布局文件xml中,将android:background属性设为@null。

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="这是默认边框"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@null"
        android:hint="这是没有边框"/>

圆角边框则是需要先设计一个圆角矩形,首先创建文件rounded_rectangle。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke android:color="#aaaaaa" android:width="1dp" android:dashGap="4dp"  android:dashWidth="10dp" />
    <corners android:radius="5dp" />
    <padding android:bottom="5dp"   //设置内边距的原因是,这样边框内的字体就可以和边框保持一定的距离,不至于太挤
        android:left="5dp"
        android:right="5dp"
        android:top="5dp"/>
</shape>

最后简单的设计布局文件,引用设计的圆角矩形:

    <EditText
        android:layout_width="match_parent"
        android:layout_marginTop="5dp"
        android:layout_height="wrap_content"
        android:background="@drawable/rounded_rectangle"
        android:hint="这个是圆角边框"/>


 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值