Android studio 如何在文本上添加笔划
我找不到在文本上(在文本上,而不是在整个文本视图框上)添加笔划的方法,笔划应该在字母周围。 是否有任何自定义文本视图或库或图形可以实现绘制笔划Android studio 如何在文本上添加笔划,android-studio,kotlin,Android Studio,Kotlin,我找不到在文本上(在文本上,而不是在整个文本视图框上)添加笔划的方法,笔划应该在字母周围。 是否有任何自定义文本视图或库或图形可以实现绘制笔划 <TextView style="@style/Header" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout
<TextView
style="@style/Header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="150dp"
android:text="HELLO DROID"
/>
我希望文本看起来是这样的,(笔划颜色是红色)
我尝试了以下两种向文本添加笔划的方法: 首先是将阴影添加到TextView:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50sp"
android:textColor="@android:color/holo_blue_light"
android:text="Hello"
android:shadowRadius="10"
android:shadowDx="1"
android:shadowDy="1"
android:shadowColor="@android:color/holo_red_dark"/>
在Java文件中添加以下代码:
StrokedTextView stroke = findViewById(R.id.stroke);
stroke.setStrokeColor(Color.RED);
stroke.setStrokeWidth(1f);
上述代码的输出为:
我希望它对你有用。你是说删除线文本吗?如果是的话,这个问题就是你的答案:@gpunto谢谢你,但不是我想要的,笔划应该在字母周围。请添加预期输出和实际输出的截图吗?@AndroidGeek editedI强烈建议不要使用该库。它在
onDraw()
中调用setTextColor()
,这会使TextView
无效,并导致无限重绘循环。仅供参考。
StrokedTextView stroke = findViewById(R.id.stroke);
stroke.setStrokeColor(Color.RED);
stroke.setStrokeWidth(1f);