I need to place an image dynamically at runtime on another Image precisely at x,y of the background Image.
I have the following details:
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 top left corner of the overlay.
Note: The x,y of the Overlay image is with respect to the background image and not the entire screen layout. The background image might get stretched when the ActionBar is hidden. The layout_width and layout_height of the background image is set to match_parent. and the scaleType is "center".
with the below code:
@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]
From many solutions and suggestions on SO, none worked for me. Believe me, am not posting this question without trying anything.