1_创建歌词显示类LyricShow:文字大小、抗锯齿、居中对齐
public class LyricShow extends TextView {
private ArrayList<Lyric> lyrics;
/**
* 画笔
*/
private Paint currentPaint;
private Paint noCurrentPaint;
//在布局文件中实例化的时候回调这个方法
public LyricShow(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
initView();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
// TODO Auto-generated method stub
super.onSizeChanged(w, h, oldw, oldh);
width = w;
height = h;
}
private void initView() {
currentPaint = new Paint();
//设置抗锯齿
currentPaint.setAntiAlias(true);
//设置颜色
currentPaint.setColor(Color.GREEN);
//设置文字大小
currentPaint.setTextSize(16);
//设置对齐
currentPaint.setTextAlign(Paint.Align.CENTER);
noCurrentPaint = new Paint();
//设置抗锯齿
noCurrentPaint.setAntiAlias(true);
//设置颜色
noCurrentPaint.setColor(Color.WHITE);
//设置文字大小
noCurrentPaint.setTextSize(16);
//设置对齐
noCurrentPaint.setTextAlign(Paint.Align.CENTER);
}
@Override
protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
canvas.drawText("没有找到歌词", width/2, height/2, currentPaint);
}
}
2_画出歌词-当前句-前句-后句
原文:http://www.cnblogs.com/ganchuanpu/p/6078732.html