自定义 EditText 样式

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

自定义 EditText 样式

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

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

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

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

自定义 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:andro
    android:shape="rectangle">

    <!-- 圆角-->
    <corners android:radius="5dp" />
    <!--描边-->
    <stroke
        android:width="1dp"
        android:color="@android:color/holo_blue_light" />

</shape>

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

自定义 EditText 样式

相关文章:

  • 2021-04-09
  • 2021-11-28
  • 2021-10-10
  • 2021-12-16
  • 2022-02-09
  • 2021-12-13
猜你喜欢
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-08-08
  • 2021-12-23
相关资源
相似解决方案