TextView去掉自身自带的内边距
来源:互联网 发布:手机检索专利软件 编辑:程序博客网 时间:2024/05/16 12:12
当输入sp比较大的文字或者数字的时候,文本或者数字周边会出现内边距的问题.
public class MyTextView extends TextView {
private boolean adjustTopForAscent = true;
public MyTextView(Context context) { super(context);}public MyTextView(Context context, AttributeSet attrs) { super(context, attrs);}public MyTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle);}Paint.FontMetricsInt fontMetricsInt;@Overrideprotected void onDraw(Canvas canvas) { if (adjustTopForAscent) {//设置是否remove间距,true为remove if (fontMetricsInt == null) { fontMetricsInt = new Paint.FontMetricsInt(); getPaint().getFontMetricsInt(fontMetricsInt); } canvas.translate(0, fontMetricsInt.top - fontMetricsInt.ascent); } super.onDraw(canvas);}
}
0 0
- TextView去掉自身自带的内边距
- 去掉GridView中自带的div
- Button去掉自带的阴影效果
- TextView 自带的跑马灯效果
- android 去掉控件自身带的边框或者按钮的方法
- android 去掉控件自身带的边框或者按钮的方法
- Android去掉自带标题栏
- 去掉状态栏中系统自带的图标的方法
- wordpress去掉自带的logo和字体的方法
- 去掉ExpandableListView的系统自带的箭头图标
- 去掉UISearchBar自带的的边框背景
- android 去掉系统自带的跳转activity的动画
- 去掉LAUNCHER中自带的SEACHER WIDGET
- Andriod: 去掉系统自带的Activity跳转动画
- 去掉LAUNCHER中自带的SEACHER WIDGET
- Andriod: 去掉系统自带的Activity跳转动画 .
- <转>Andriod: 去掉系统自带的Activity跳转动画
- iOS去掉icon的(自带磨光效果)gloss effects
- 185.User SCOTT executes the following command on the EMP table but has not issued COMMIT, ROLLBACK,
- cocoapods:常见错误总结+Mac OS 10.11
- struts2 图片上传 详解
- 生成一个集合的所有子集 Subset
- 关于解决android studio各种疑难杂症系列---- 工程的geadle版本跟当前环境不匹配
- TextView去掉自身自带的内边距
- [leetcode] 215. Kth Largest Element in an Array
- jquery 对 Json 的各种遍历
- 186.User A executes the following command to drop a large table in your database: SQL> DROP TABLE tr
- POJ 1141 Brackets Sequence(区间DP)
- MATLAT2012B安装license checkout failed
- IT相关证书
- 兼容ie select option 显示隐藏
- 187.Which two statements describe good practices for an application developer to reduce locking conf