Android EditText 半圆角

2024-05-27 04:48
文章标签 android edittext 半圆

本文主要是介绍Android EditText 半圆角,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1、左上和右上是圆角

首先在res/drawable中创建一个edittext_no_buttom.xml(shape),没有drawable则新建一个即可

edittext_no_buttom.xml的代码如下

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" ><solid android:color="#FFFFFF" /><strokeandroid:width="0.01dp"android:color="#BFBFBF" /><!-- 圆角 --><cornersandroid:bottomLeftRadius="0.1dp"android:bottomRightRadius="0.1dp"android:topLeftRadius="10.0dp"android:topRightRadius="10.0dp" /></shape>

2、左下和右下是圆角

首先在res/drawable中创建一个edittext_no_top.xml(shape),没有drawable则新建一个即可

edittext_no_top.xml的代码如下

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" ><solid android:color="#FFFFFF" /><strokeandroid:width="0.01dp"android:color="#BFBFBF" /><!-- 圆角 --><cornersandroid:bottomLeftRadius="10.0dp"android:bottomRightRadius="10.0dp"android:topLeftRadius="0.1dp"android:topRightRadius="0.1dp" /></shape>

3、这个我是在我的登录界面中使用,login.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_marginLeft="10.0dp"android:layout_marginRight="10.0dp"android:layout_marginTop="-16.0dp"android:background="@drawable/edittext_no_buttom" >  --我是在这引用左上右上<RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content" ><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10.0dp"android:layout_marginTop="5.0dp"android:background="@drawable/user" /><EditTextandroid:id="@+id/txt_username"android:layout_width="match_parent"android:layout_height="40.0dp"android:layout_marginBottom="2.0dp"android:layout_marginLeft="48.0dp"android:layout_marginRight="10.0dp"android:layout_marginTop="2.0dp"android:background="@color/transparent"android:hint="@string/login_username"  --请输入账号android:inputType="text"android:singleLine="true"android:textSize="14.0sp" /></RelativeLayout></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_marginLeft="10.0dp"android:layout_marginRight="10.0dp"android:layout_marginTop="-1.0dp"android:background="@drawable/edittext_no_top" >  --我是在这引用左下右下<RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content" ><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10.0dp"android:layout_marginTop="5.0dp"android:background="@drawable/pwd" /><EditTextandroid:id="@+id/txt_pwd"android:layout_width="match_parent"android:layout_height="40.0dp"android:layout_marginBottom="2.0dp"android:layout_marginLeft="48.0dp"android:layout_marginRight="10.0dp"android:layout_marginTop="2.0dp"android:background="@color/transparent"android:ems="10"android:hint="@string/login_password"  --请输入密码android:inputType="textPassword"android:singleLine="true"android:textSize="12.0sp" ></EditText></RelativeLayout></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_marginTop="5.0dp"android:orientation="vertical" ><Buttonandroid:id="@+id/btn_login"android:layout_width="match_parent"android:layout_height="42.0dp"android:layout_gravity="right"android:layout_marginLeft="10.0dp"android:layout_marginRight="12.0dp"android:background="@drawable/btn_login_x"android:text="@string/action_login"android:textColor="@color/white" /></LinearLayout> 
</LinearLayout>

效果图:


这篇关于Android EditText 半圆角的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1006549

相关文章

Android学习总结之Java和kotlin区别超详细分析

《Android学习总结之Java和kotlin区别超详细分析》Java和Kotlin都是用于Android开发的编程语言,它们各自具有独特的特点和优势,:本文主要介绍Android学习总结之Ja... 目录一、空安全机制真题 1:Kotlin 如何解决 Java 的 NullPointerExceptio

Android NDK版本迭代与FFmpeg交叉编译完全指南

《AndroidNDK版本迭代与FFmpeg交叉编译完全指南》在Android开发中,使用NDK进行原生代码开发是一项常见需求,特别是当我们需要集成FFmpeg这样的多媒体处理库时,本文将深入分析A... 目录一、android NDK版本迭代分界线二、FFmpeg交叉编译关键注意事项三、完整编译脚本示例四

Android与iOS设备MAC地址生成原理及Java实现详解

《Android与iOS设备MAC地址生成原理及Java实现详解》在无线网络通信中,MAC(MediaAccessControl)地址是设备的唯一网络标识符,本文主要介绍了Android与iOS设备M... 目录引言1. MAC地址基础1.1 MAC地址的组成1.2 MAC地址的分类2. android与I

Android 实现一个隐私弹窗功能

《Android实现一个隐私弹窗功能》:本文主要介绍Android实现一个隐私弹窗功能,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 效果图如下:1. 设置同意、退出、点击用户协议、点击隐私协议的函数参数2. 《用户协议》、《隐私政策》设置成可点击的,且颜色要区分出来res/l

Android实现一键录屏功能(附源码)

《Android实现一键录屏功能(附源码)》在Android5.0及以上版本,系统提供了MediaProjectionAPI,允许应用在用户授权下录制屏幕内容并输出到视频文件,所以本文将基于此实现一个... 目录一、项目介绍二、相关技术与原理三、系统权限与用户授权四、项目架构与流程五、环境配置与依赖六、完整

Android 12解决push framework.jar无法开机的方法小结

《Android12解决pushframework.jar无法开机的方法小结》:本文主要介绍在Android12中解决pushframework.jar无法开机的方法,包括编译指令、框架层和s... 目录1. android 编译指令1.1 framework层的编译指令1.2 替换framework.ja

Android开发环境配置避坑指南

《Android开发环境配置避坑指南》本文主要介绍了Android开发环境配置过程中遇到的问题及解决方案,包括VPN注意事项、工具版本统一、Gerrit邮箱配置、Git拉取和提交代码、MergevsR... 目录网络环境:VPN 注意事项工具版本统一:android Studio & JDKGerrit的邮

Android实现定时任务的几种方式汇总(附源码)

《Android实现定时任务的几种方式汇总(附源码)》在Android应用中,定时任务(ScheduledTask)的需求几乎无处不在:从定时刷新数据、定时备份、定时推送通知,到夜间静默下载、循环执行... 目录一、项目介绍1. 背景与意义二、相关基础知识与系统约束三、方案一:Handler.postDel

Android使用ImageView.ScaleType实现图片的缩放与裁剪功能

《Android使用ImageView.ScaleType实现图片的缩放与裁剪功能》ImageView是最常用的控件之一,它用于展示各种类型的图片,为了能够根据需求调整图片的显示效果,Android提... 目录什么是 ImageView.ScaleType?FIT_XYFIT_STARTFIT_CENTE

Android实现在线预览office文档的示例详解

《Android实现在线预览office文档的示例详解》在移动端展示在线Office文档(如Word、Excel、PPT)是一项常见需求,这篇文章为大家重点介绍了两种方案的实现方法,希望对大家有一定的... 目录一、项目概述二、相关技术知识三、实现思路3.1 方案一:WebView + Office Onl