首页 > 移动平台 > 详细

手机影音12--显示歌词

时间:2016-11-18 21:34:36      阅读:265      评论:0      收藏:0      [点我收藏+]

1_创建歌词显示类LyricShow

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_画出歌词-当前句-前句-后句  

手机影音12--显示歌词

原文:http://www.cnblogs.com/ganchuanpu/p/6078732.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!