答案 0 :(得分:2)
在互联网上找到某个地方。我创建了一个自定义textview,并在onDraw方法中使用了下面的代码,它使用画布绘制来创建textview效果的Text Outline。
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
if(strokeColor!=null)
{
val textColor = textColors
val paint = this.paint
paint.style = Paint.Style.STROKE
paint.strokeJoin = strokeJoin
paint.strokeMiter = strokeMiter //10f
this.setTextColor(strokeColor)
paint.strokeWidth = strokeWidth //15f
super.onDraw(canvas)
paint.style = Paint.Style.FILL
setTextColor(textColor)
super.onDraw(canvas)
}
}
答案 1 :(得分:0)
查看此library
示例强>
alert(document.getElementById("normal").innerHTML="from custom");
示例2
<com.biomorgoth.outlinetextview.StrokedTextView
android:id="@+id/your_text_view"
android:text="I am a StrokedTextView!"
android:textColor="@android:color/white"
android:textSize="25sp"
strokeAttrs:textStrokeColor="@android:color/black"
strokeAttrs:textStrokeWidth="1.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />