I want to position an image dynamically.
setX and setY works fine, but in pixels. I want my app to be escalable to every device's screen. Furthermore, I want it to work in landscape mode.
What's the proper method?
I want to position an image dynamically.
setX and setY works fine, but in pixels. I want my app to be escalable to every device's screen. Furthermore, I want it to work in landscape mode.
What's the proper method?
setX and setY aren't the proper way to position images in Android.
You have to use either LinearLayout or RelativeLayout to have a design supported on any orientations and any devices.
Layouts and ImageViews can be created and added dynamically.
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.mylayout)
TextView txt1 = new TextView(MyClass.this);
linearLayout.setBackgroundColor(Color.TRANSPARENT);
linearLayout.addView(txt1);
Thanks the source code author : Deepak
You only have to change TextView for ImageView.