package com.zongyi.trip.ui;

import com.zongyi.trip.R;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.PathEffect;
import android.util.AttributeSet;
import android.widget.EditText; @SuppressLint({ "ResourceAsColor", "DrawAllocation" })
public class LinedEditText extends EditText {
// private Paint mPaint = new Paint(); public LinedEditText(Context context) {
super(context);
initPaint();
} public LinedEditText(Context context, AttributeSet attrs) {
super(context, attrs);
initPaint();
} public LinedEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initPaint();
} private void initPaint() {
// mPaint.setStyle(Paint.Style.STROKE);
//// mPaint.setColor(0x80000000);
// mPaint.setStyle(Paint.Style.STROKE);
// mPaint.setColor(R.color.dashed_line_color);
// PathEffect effects = new DashPathEffect(new float[]{5,5,5,5},1);
// mPaint.setPathEffect(effects);
} @Override protected void onDraw(Canvas canvas) {
Paint mPaint = new Paint();
// mPaint.setColor(0x80000000);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(Color.LTGRAY);
PathEffect effects = new DashPathEffect(new float[]{5,5,5,5},5);
mPaint.setPathEffect(effects); int left = getLeft();
int right = getRight();
int paddingTop = getPaddingTop();
int paddingBottom = getPaddingBottom();
int paddingLeft = getPaddingLeft();
int paddingRight = getPaddingRight();
int height = getHeight();
int lineHeight = getLineHeight();
int spcingHeight = (int) getLineSpacingExtra();
int count = (height-paddingTop-paddingBottom) / lineHeight; for (int i = 0; i < count; i++) {
int baseline = lineHeight * (i+1) + paddingTop - spcingHeight/2 ;
canvas.drawLine(left+paddingLeft, baseline, right-paddingRight, baseline, mPaint);
} super.onDraw(canvas);
}
}
 <com.zongyi.trip.ui.LinedEditText
android:id="@+id/edittext_message"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:lineSpacingExtra="15dp"
android:gravity="top"
android:textColor="#ACB6BB"
android:textSize="18sp" />

笔记本样式的EditText控件(每行均带下划虚线)的更多相关文章

  1. Android EditText控件行尾为表情时的BUG

    今天处理项目上的一个诡异BUG,贴吧Android客户端发贴框是支持表情文字混排的,但是当发贴框的行内容末尾为表情时,尝试在表情后插入文字,就悲剧了:文字其实写进去了,但是不会显示出来.研究了一下,发 ...

  2. 【我的Android进阶之旅】如何隐藏Android中EditText控件的默认下划线

    Android EditText控件是经常使用的控件,但是有时候我们并不需要它的一些默认的属性,比如说下划线,因为有时候这样的默认下划线看起来特别怪异,和其他控件在一起搭配的时候不协调,因此有时候就需 ...

  3. C语言Windows程序开发—Windows窗口样式与常用控件样式【第04天】

    (一)Windows窗口(MDICLIENT)样式介绍 /* Windows窗口样式 */ WS_BORDER //带有边框的窗口 WS_CAPTION //带有标题栏的窗口 WS_CHILD //子 ...

  4. Flutter样式和布局控件简析(二)

    开始 继续接着分析Flutter相关的样式和布局控件,但是这次内容难度感觉比较高,怕有分析不到位的地方,所以这次仅仅当做一个参考,大家最好可以自己阅读一下代码,应该会有更深的体会. Sliver布局 ...

  5. WPF自定义控件与样式(9)-树控件TreeView与菜单Menu-ContextMenu

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: 菜单M ...

  6. WPF自定义控件与样式(10)-进度控件ProcessBar自定义样

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: Pro ...

  7. EditText控件实现只读

      android的EditText控件实现只读只需设置三个方法: editText.setCursorVisible(false);//隐藏光标 editText.setFocusable(fals ...

  8. WPF-实现Windows 7 样式 Aero TreeView 控件

    关于实现Windows 7 样式 Aero TreeView 控件的具体过程可以参考如下文章 http://www.cnblogs.com/o2ds/archive/2010/06/22/176302 ...

  9. Android 动态背景的实现以及SurfaceView中添加EditText控件

    首先还是一贯作风,我们先看案例: \ 静态图看不出来效果,如果用过此软件(扎客)的同学们都知道,她的背景会动.怎么样,是不是觉得很时尚,起码比静态的要好(个人观点).其实实现起来并不复杂,这个如果让做 ...

随机推荐

  1. Codeforces Round #228 (Div. 1) B. Fox and Minimal path 构造

    B. Fox and Minimal path 题目连接: http://codeforces.com/contest/388/problem/B Description Fox Ciel wants ...

  2. HDU 1692 Destroy the Well of Life 水题

    Destroy the Well of Life Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showprob ...

  3. ZOJ 3631 Watashi's BG DFS

    J - Watashi's BG Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Subm ...

  4. 基于Landmark的人脸对齐以及裁剪方法

    利用Landmarks进行人脸对齐裁剪是人脸检测中重要的一个步骤.效果如下图所示: 基本思路为: a.人脸检测 人脸的检测不必多说了,基本Cascade的方式已经很不错了,或者用基于HOG/FHOG的 ...

  5. MySQL增强版命令行客户端连接工具(mycli)

    效果: 安装: http://www.mycli.net/install 官网: http://www.mycli.net/install

  6. maven打包出错: Failed to clean project: Failed to delete

    maven打包出错: Failed to clean project: Failed to delete 出现这种错误,通常是由于您已启动了另一个tomcat 进程,导致报错,关闭tomcat进程即可 ...

  7. MVC之Ajax如影随行

    一.Ajax的前世今生 我一直觉得google是一家牛逼的公司,为什么这样说呢?<舌尖上的中国>大家都看了,那些美食估计你是百看不厌,但是里边我觉得其实也有这样的一个哲学:关于食材,对于种 ...

  8. springboot线程池的使用和扩展

    我们常用ThreadPoolExecutor提供的线程池服务,springboot框架提供了@Async注解,帮助我们更方便的将业务逻辑提交到线程池中异步执行,今天我们就来实战体验这个线程池服务: 本 ...

  9. 解决ElasticSearch5.x中@Field注解之IK分词不能用的问题

    一.概述 环境:ElasticSearch版本5.6.3,SpringBoot 2.0.2.RELEASE,索引myIndex 问题描述:使用@Field注解给实体类指定ik分词解析器(ik_smar ...

  10. 【spring cloud】spring cloud zuul 路由网关

    GitHub源码地址:https://github.com/AngelSXD/springcloud 版本介绍: <properties> <project.build.source ...