TextView下划线的添加,控制下划线和文字的距离
2018-02-28 16:01
357 查看
下面是效果图:
图片:因为在思考这个效果的时候花了一点时间,所以记录了这个过程:首先实现上面效果我们首先会想到是什么?没错就是TextView的自带的下划线的属性:
holder.tvCount.setPaintFlags(Paint. UNDERLINE_TEXT_FLAG); holder.tvCount.getPaint().setAntiAlias(true);//这里要加抗锯齿1
2
不过这个实现的是下划线贴在文字的下面,效果不是很好,一般设计师大人也不会这么设计。
然后我想到在下面添加一个横线不就好了,不过多番尝试后发现下划线无法跟随上面文字长短变化,这里要怎么简单处理?这里思考,想让下面的线和上面长短变化相同,怎么做比较简单?聪明的你应该已经想到了,就是在下面在放一个TextView不就好了,然后也设置和上面一样的文字给它,他们不就一样了
补充
下面是同学留言说的方法,可以实现上述效果,感谢赐教。下面是代码:
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/tv_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="2" /> <View android:layout_width="wrap_content" android:layout_height="1dp" android:layout_alignBottom="@+id/tv_count" android:layout_alignEnd="@+id/tv_count" android:layout_alignStart="@+id/tv_count" android:background="@color/colorAccent" android:minWidth="4dp" /> </RelativeLayout>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
结束
相关文章推荐
- TextView下划线的添加,控制下划线和文字的距离
- Andorid中如果在TextView中用drawable添加图片,怎么能改变图片与文字的距离
- 给TextView的文字添加下划线
- 给TextView的文字添加下划线
- TextView文字下划线的添加
- Android TextView控件文字添加下划线
- Andorid中如果在TextView中用drawable添加图片,怎么能改变图片与文字的距离
- Android TextView控件文字添加下划线的实现方法
- Android TextView控件文字添加下划线
- TextView 多行文字末尾添加图片
- Android TextView文字过多,添加滚动条 分类: Android 2015-07-21 13:39 2人阅读 评论(0) 收藏
- 给textview 添加下划线
- 关于TextView文字下划线
- 把TextView中的文字添加阴影效果及Style的使用
- Android TextView 添加下划线的几种方式
- Android TextView文字过多,添加滚动条
- Android TextView 添加下划线的简单方法
- 关于TextView文字下划线
- 自定义TextView中的文字之间设置子间距离
- 设置TextView部分文字下划线并响应点击事件(SpannableString)