view invalidate特别卡为何?

嘿仔晨 发布于 2012/05/09 10:29
阅读 377
收藏 0

activity 中有个view;在view 绘制了一串文字跑动,和时间图片;需要在绘制完毕后invalidate();却发现文字在移动是特别的卡;要如何解决呢?
若不画图片的话文字移动就不卡了,何解?

class ViewText extends View{
		AbsoluteLayout.LayoutParams g_LayoutParams;
		int step=300;
		private Bitmap map_seconds_1;
		private Bitmap map_seconds_2;
		public ViewText(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
			g_LayoutParams=new AbsoluteLayout.LayoutParams(222,333,11,20);
		}
		@Override 
		protected void onDraw(Canvas canvas) {
			
			itime();
			canvas.drawBitmap(map_seconds_1, null, new Rect(204,0,214,30),null);
			canvas.drawBitmap(map_seconds_2, null, new Rect(216,0,226,30),null);
			
            Paint paint = new Paint();   
            paint.setColor(Color.BLUE);   
            paint.setTextSize(33);
			canvas.drawText("跑马灯", step, 50, paint);
			step-=3;
			if(step<-30)
				step = 300;
			invalidate();
		}
		public void itime(){
			SimpleDateFormat ft=new SimpleDateFormat( "yyyy-MM-dd HH🇲🇲ss");
			String str = ft.format((new Date()));
			map_seconds_1 = BitmapFactory.decodeFile("/mnt/sdcard/media/9000_0"+str.substring(17,18)+".png");
			map_seconds_2 = BitmapFactory.decodeFile("/mnt/sdcard/media/9000_0"+str.substring(18,19)+".png");
		}
	}

加载中
返回顶部
顶部