How to dynamically move a textview on a screen? (Framelayout)

I have an application that shows the view of the camera on the screen in FrameLayout. The screen is in LandScape fixed mode.

I need to write a textView with dynamically defined screen coordinates. Coordinates are defined as a percentage, for example:

write the text at the coordinates x = 80% of the screen and y = 20% of the screen. write a text image at the coordinates x = 35% of the screen and y = 55% of the screen.

how to do it? I already have percentages, I only need to know how to use them to write a textual representation in the desired frameLayout position

code examples are welcome

I tried with this, but it does not work, the text image does not move:

TextView poi..... etc etc
poi.setLayoutParams(new LayoutParams((int)(w*(xCoordPercent/100)), h/2));

thank

+5
1
MarginLayoutParams params=(MarginLayoutParams )poi.getLayoutParams();
params.leftMargin=80;
//here 100 means 100px,not 80% of the width of the parent view
//you may need a calculation to convert the percentage to pixels. 
params.topMargin=50;
poi.setLayoutParams(params);

.

+3

All Articles