Search code examples
androidimagearrow-keys

Android: How to place arrow keys (using images)


Just like in many games, I want to do something similar in my app. A set of arrow keys on the bottom left part of the screen so you can control the app.

The thing is, each arrow would be an image. But how to position each of them and how to handle the size is what's confusing me. Why? Because I don't want to use fixed images, I want them to adjust (scale and move) automatically depending on the screen size.

Any tip on how to handle this?

EDIT: What I have tried so far was to use a gridlayout, but in a xml layout I can't make the cells work with percentages nor using relative values.

So yeah, as far as I can get is to align that gridlayout on the bottom-left, I get the images look like one of the answers below but I can't adjust the size of each image to look relative to each different screen.... Currently, in a small screen you would see the images HUGE. And in a big screen you would see 'em ok


Solution

  • I haven't tried this but it seems pretty simply. Just use a TableLayout and then fill the cells you want with the respective button.

     ___________________
    |      |      |     |
    |      |  Up  |     |
    |______|______|_____|
    |      |      |     |
    | Left | Down |Right|
    |______|______|_____|