Search code examples
androidimagecoordinatescss-positionandroid-framelayout

Positioning an image on top of an image with specific coordinates in Android


End Goal: Getting a speedometer style needle to move around a dial according to test results.

Current Issue: At the moment I have placed the needle on top of the speed dial as a sperate image using FrameLayout. I have been scouring the web for a way to position the needle with coordinates so I can have it exactly where I want it on the dial. I would post an image but I'm new to the forum and I'm not allowed!

So in short can I position an image over another image with exact coordinates (allowing for rotation etc)? Am I going the right way about solving my problem?


Solution

  • There is the AbsoluteLayout, which lets you use absolute positions, but it is not recommended that you use it.

    Instead, you should create your own extension of a View, that draws your dial and needle. For more info on this, look at Maurycy's comment, which recommends this part of the manual.