Android中的美丽描边文字

我知道如何使用自定义视图(EditText或TextView)来描边文字但我无法实现像这样的美丽的东西,这是使用Photoshop完成的.是的,它也有外影.

到目前为止我所做的是调整笔画宽度和笔画连接样式.但是,如果我增加笔划宽度,则笔划会发生整个文本.
据我所搜索,有一个名为MagicTextView的库,但它也无法给出如上所述的结果.

更新:我根据@pskink的建议调整了一些内容.它现在有效.但是我不能再拖了.如果我拖动EditText,会出现一些像这样的奇怪线条.

这是代码:

@Override public void onDraw(Canvas canvas) {
  final int x = this.getLeft();
  final int y = this.getBottom();

  mText = this.getText().toString();

  p.setStrokeWidth(30);
  p.setStyle(Style.STROKE);
  p.setStrokeJoin(Join.ROUND);
  p.setColor(0xffffffff);

  canvas.drawText(mText,x,y,p);

  p.setStyle(Style.FILL);
  p.setColor(0xff000000);

  canvas.drawText(mText,p);
}

解决方法

However,if I increase the stroke width,the stroke took place the whole text.

如果问题是笔划居中,并且您希望笔划在文本之外,请参阅:Android Paint stroke width positioning

You must precalculate the desired width and height according to your stroke.

我建议尝试一种非常大胆的字体.在下图中,白色笔划将以红线为中心(这将是每个黑色字母的轮廓).

为了回应您的更新:

If I drag that EditText,there is some weird lines showed up.

该行可能是关注EditText的结果.您可以明确删除焦点:Android: Force EditText to remove focus?

或者,您可以设置焦点样式(如果它不会对UI的其余部分产生负面影响,则可能是不可见的):How to change the color of a focused EditText when using “android:Theme.Holo.Light”?

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...