手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android中EditText如何去除边框添加下划线
Android中EditText如何去除边框添加下划线
摘要:废话不多说了,直接给大家贴代码了。其中background,可以设置成其他颜色等textColor不一定要是null,可以设置字体颜色加下划...

废话不多说了,直接给大家贴代码了。

<span><"1.0" encoding="utf-8"?> </span> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <> <com.marine.study.LineEditText android:id="@+id/myEdit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@null" android:textColor="@null" /> </LinearLayout>

其中background,可以设置成其他颜色等

textColor不一定要是null,可以设置字体颜色

加下划线

public class LineEditText extends EditText { // 画笔 用来画下划线 private Paint paint; public LineEditText(Context context, AttributeSet attrs) { super(context, attrs); paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.RED); // 开启抗锯齿 较耗内存 paint.setAntiAlias(true); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // 得到总行数 int lineCount = getLineCount(); // 得到每行的高度 int lineHeight = getLineHeight(); // 根据行数循环画线 for (int i = 0; i < lineCount; i++) { int lineY = (i + 1) * lineHeight; canvas.drawLine(0, lineY, this.getWidth(), lineY, paint); } } }

以上内容给大家介绍了Android中EditText如何去除边框添加下划线的相关内容,希望对大家有所帮助!

【Android中EditText如何去除边框添加下划线】相关文章:

Android开发之相对布局

设置android 文字下划线

android dialog边框去除白色边框实现思路及代码

android 如何判断当前是否为飞行模式

Android开发中如何获取应用版本号

Android笔记之:App列表之下拉刷新的使用

android ListView内数据的动态添加与删除实例代码

Android自定义Custom Dialog对话框

Android控件系列之EditText使用方法

android ListView深入理解

精品推荐
分类导航