I'm new in the Android world and I have a very annoying problem. In my program I use the Android Canvas. I'd like to add an EditText element, or something like that, to get user text inputs. Can you help me find a way to solve this problem?
Thanks for the answers.
Initially, you cannot place any edit text or buttonsusig canvas. Instead, you have to draw it. So create a custom layout and draw that layout with canvas
Try this, It might help you. in onDraw(..)
LinearLayout lL = new LinearLayout(context);
EditText editTextView = new EditText(context);
editTextView.setVisibility(View.VISIBLE);
lL.addView(editTextView);
lL.measure(canvas.getWidth(), canvas.getHeight());
lL.layout(0, 0, canvas.getWidth(), canvas.getHeight());
// placing the edit text at specific co-ordinates:
//canvas.translate(0, 0);
layout.draw(canvas);
And take a look at this another example : Click here
It gives another way of adding views
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With