I want to draw some text inside my layout that is full screen the problem is i can get an accurate point. Here is what i coded:
DisplayMetrics display = getResources().getDisplayMetrics();
int width = display.widthPixels;
String data_azi = DateFormat.getDateTimeInstance().format(new Date());
cnv.drawText(data_azi, width - p.measureText(data_azi), 40,p);
you need to measure upfront and use that measurement during drawing time. For example you could call
measureText()at init time. This method measures the width of the current date and adds 20% to the measured width.Then you draw like this:
Also make sure that your paint object is left aligned
p.setTextAlign(Align.LEFT);