1.[代码][Java]代码
package com.example.testproject;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint.Style;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.TextView;
/*
* StrokeTextView的目标是给文字描边
* 实现方法是两个TextView叠加,只有描边的TextView为底,实体TextView叠加在上面
* 看上去文字就有个不同颜色的边框了
*/
public class StrokeTextView extends TextView {
private TextView borderText = null;///用于描边的TextView
public StrokeTextView(Context context) {
super(context);
borderText = new TextView(context);
init();
}
public StrokeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
borderText = new TextView(context,attrs);
init(