In my Android app I have an ImageView which displays an image from assets. What I need to do is to display a text almost centered in the image (what I mean by almost centered is aligned to a rectangle which is near from the center of the image). I know the (x, y) coordinates of this point (in pixels), but when I switch from device to device, of course, this pixels vary. I have tried using dp, with no luck.
So, what I want to do is to display text inside this rectangle. I have the (x, y) coordinates of each point of the rectangle (in pixels relative to the emulator).
How can I do to make that design responsive?
Thank you
答案 0 :(得分:1)
Put the image in a relativelayout... And add the textView(with centerInParent) to the relative layout...
答案 1 :(得分:0)
Try making the position relative to the Image not the Emulator.
So when you go across different devices you can multiply both values by the same scale factor.