Code example for DynamicLayout

Methods: drawgetLineBaselinegetWidth

0
		TextPaint sm = new TextPaint(Paint.ANTI_ALIAS_FLAG|Paint.SUBPIXEL_TEXT_FLAG|Paint.DEV_KERN_TEXT_FLAG);
		sm.setTypeface(Typeface.DEFAULT_BOLD);
		sm.setTextSize(getWidth() / 5.5f);
		sm.setColor(Color.WHITE);
		//sm.setShadowLayer(10.f, 7, 7, Color.BLACK); 
		DynamicLayout dl = new DynamicLayout("Sharemore", sm, getWidth(), Alignment.ALIGN_NORMAL, 0.f, 0.f, true);
		 
		 
		 
		Paint pm = new Paint(Paint.ANTI_ALIAS_FLAG|Paint.DITHER_FLAG);
		Paint lightGray = new Paint(pm);
		lightGray.setColor(Color.argb(0xff, 0xcc, 0xcc, 0xcc));
		lightGray.setStyle(Style.STROKE);
		 
		 
		 
		Rect r = new Rect(10,10,dl.getWidth()-10,getHeight()-10);
		pm.setColor(Color.argb(0xcc, 0xff, 0xff, 0xff));
		canvas.drawRect(r, pm );
		canvas.drawRect(r, lightGray);
		 
		int titleB = dl.getLineBaseline(0)+10;
		RectF title = new RectF(0,0,getWidth(),titleB);
		pm.setColor(Color.DKGRAY);
		canvas.drawRect(title, pm);
		RectF titleG = new RectF(0,titleB,getWidth(),titleB+10);
		Paint titleGP = new Paint(pm);
		LinearGradient tlg = new LinearGradient(0, titleB, 0, titleB+10, Color.DKGRAY, Color.TRANSPARENT, TileMode.REPEAT);
		titleGP.setShader(tlg);
		canvas.drawRect(titleG, titleGP);
		 
		 
		canvas.save();
		canvas.translate(10, 0);
		dl.draw(canvas);
		canvas.restore();
		 
		 
	} 
 
Stop searching for code, let great code find you!  Add Codota to your java IDE