Is there a way to programatically add TextView and show it right next to the ImageView user clicked on?
I tried something like this, but no results, TextView is added to the bottom of my layout:
TextView score = new TextView(getBaseContext());
score.setText("Image clicked");
Rect rectf = new Rect();
im.getLocalVisibleRect(rectf);
AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 300, 270);
score.setLayoutParams(params);
layout.addView(score);
First thing, never use AbsoluteLayout, never! AbsoluteLayout is generally not recommended and you shouldn’t use it. I recommend to you use
RelativeLayoutand then you only need to add rule.Try to use following snippet of code: