开发者

Adding EditText box to android app based on x,y coordinates?

开发者 https://www.devze.com 2023-04-06 07:21 出处:网络
I am looking to be able to first detect touch events to draw a box whatever size the user wants on the canvas - this part I have completed.

I am looking to be able to first detect touch events to draw a box whatever size the user wants on the canvas - this part I have completed.

I then need to take the coordinates of that box and create a edit开发者_JS百科text box in its place. Any Suggestions ? I would then like to make the text entered become part of the canvas itself, no longer editable any ideas there either ?

thanks!


Use AbsoluteLayout and add touch listener via setOnTouchListener(..)

Then when touch happens, detect the location and add EditText via

AbsoluteLayout.LayoutParams layoutParams = 
    new AbsoluteLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, x, y);
absoluteLayout.addView(editText, layoutParams);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号