我有一个应用程序,可以在屏幕上的 FrameLayout 上显示相机视图。屏幕处于固定风景模式。
我需要编写一个带有动态确定的屏幕坐标的textView。坐标以百分比确定,例如:
将文本视图写入屏幕坐标 x=80% & y=20% 屏幕上。将文本视图写在屏幕的 x=35% 和 y=55% 的屏幕坐标上。
怎么做?我已经有了百分比,我只需要知道如何使用它们在框架布局的所需位置上写入文本视图
欢迎使用代码示例
我尝试过这个,但不起作用,文本视图没有移动:
TextView poi..... etc etc
poi.setLayoutParams(new LayoutParams((int)(w*(xCoordPercent/100)), h/2));
thanks
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);
这可能会有所帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)