Code example for StaticLayout

Methods: drawgetHeightgetWidth

0
		else { 
			fromLay = new StaticLayout(from, txtP, this.getWidth() - rpad,Layout.Alignment.ALIGN_NORMAL, 1.3f, 0, false);
		} 
		 
		StaticLayout timelay  = new StaticLayout(time, txtP, this.getWidth() - rpad,Layout.Alignment.ALIGN_OPPOSITE, 1.3f, 0, false);
		StaticLayout layout  = new StaticLayout(message, txtP, this.getWidth() - rpad,Layout.Alignment.ALIGN_NORMAL, 1.3f, 0, false);
		if (picture != null) {
			this.setLayoutParams(new LayoutParams(this.getWidth(), fromLay.getHeight() + 
																   layout.getHeight() + 
																   timelay.getHeight() +
																   vpad +
																   picture.getHeight()));
		} else 
			this.setLayoutParams(new LayoutParams(this.getWidth(), layout.getHeight() +
																   timelay.getHeight() +
																   vpad +
																   fromLay.getHeight()));
		if (profile != null) {
			canvas.drawBitmap(profile, lpad, 0, msgP);
		} 
		 
		topBar = timelay.getHeight();
		 
		txtP.setFakeBoldText(true);
		txtP.setColor(Color.rgb(59, 89, 152));		// Facebook Blue
		if (profile != null) {
			canvas.translate(profile.getWidth() + lpad + fpad, 0);
			fromLay.draw(canvas);
			canvas.translate(-profile.getWidth() - fpad, 0);
		} else { 
			canvas.translate(lpad, 0);
			fromLay.draw(canvas);
		} 
		//lpad already on canvas 
		canvas.translate(0, fromLay.getHeight());
		timelay.draw(canvas);
		 
		//txtP.setTextSize(16); 
		txtP.setFakeBoldText(false);
		txtP.setColor(Color.BLACK);
		canvas.translate(0, topBar);
		layout.draw(canvas);
		if (picture != null) {
			//canvas.translate(0, layout.getHeight()); 
			canvas.drawBitmap(picture, layout.getWidth()/2 - picture.getWidth()/2, layout.getHeight(), msgP);
		} 
		 
	} 
	 
	private void init() { 
Stop searching for code, let great code find you!  Add Codota to your java IDE