关于Edittext的一些事情

1、隐藏android中EditText自带的的下划线

android:background="@null"
或android:background="@/drawable/bg_edittext_norma.xml"

bg_edittext_norma.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!--商品描述的可编辑框-->
    <solid android:color="#FFFFFF" />
    <corners android:radius="10dip"/>
    <stroke
        android:width="1dip"
        android:color="#BDC7D8" />
</shape>
<EditText
       style="?android:attr/textViewStyle"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:background="@null"
       android:hint="输入用户名"
       android:paddingBottom="5dip"
       android:paddingTop="5dip" />

2、多行EditText的时候会出现光标在中间的问题:
关键代码

android:gravity="left"
<EditText   
    android:layout_width="match_parent"  
    android:layout_height="wrap_content"  
    android:minLines="5"  
    android:background="#ffffff"  
    android:paddingLeft="5dp"  
    android:gravity="left" />  

像这种。这是什么原因造成的呢?用来EdittText默认是gravity是center.就是从中间对齐。我们把他改成left啊top啊就OK了。

3、修改EditText的光标颜色
在使用EditText的XML 文件中加入一个属性:

android:textCursorDrawable="@null"
//或者
android:textCursorDrawable = "#fff000"

这个属性是用来控制光标颜色的,"@null" 是作用是让光标颜色和text color一样,当然也可以修改成你自己的颜色。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容