自定义 EditText 样式

极力推荐文章:欢迎收藏
Android 干货分享

阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android

本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:

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

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

自定义EditText 背景

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

自定义圆角矩形custom_edittext_background.xml


    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/custom_edittext_background"
        android:gravity="center"
        android:hint="自定义EditText"
        android:padding="8dp"
        android:textSize="16sp" />

2.自定义EditText 背景

<?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>

至此,本篇已结束,如有不对的地方,欢迎您的建议与指正。同时期待您的关注,感谢您的阅读,谢谢!

微信关注公众号: 程序员Android,领福利

猜你喜欢

转载自www.cnblogs.com/wangjie1990/p/11310740.html