I need to place the image dynamically at runtime on another image exactly in the x, y of the background image .
I have the following data:
Overlay image attributes (red): x = 58, y = 232, h = 266, w = 431
Background image (black): match_parent, w = 1024, h = 768
Here x, y is the upper left corner of the overlay.
Note. x, y of the image Overlay is related to the background image, not the entire screen. The background image may stretch when you hide the ActionBar. The layout_width and layout_height of the background image are set to match_parent. and scaleType is the "center".
with the code below:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RelativeLayout root = (RelativeLayout) findViewById(R.id.rootlayout); backIV = (ImageView) findViewById(R.id.imageView1); Content = new ImageView(this); Content.setImageDrawable(getResources().getDrawable(R.drawable.content_1)); params = new RelativeLayout.LayoutParams(431, 266); rl.addView(Content, params); root.addView(rl); }
From the code above :

[What I want]

Of the many SO solutions and suggestions, none worked for me. Believe me, I am not posting this question without trying anything.
source share