0

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

1 Answers1

1

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|
|______|______|_____|
Rawa
  • 13,357
  • 6
  • 39
  • 55
  • If I use a table layout how am I gonna get the right size for each cell so the table looks good in ALL devices? I tried a Gridlayout before, but I don't have much idea of how to adjust the size of its cells depending on the screen size, and how to make the images stretch as max as the cell allows. – user3785125 Jul 22 '14 at 11:24
  • Simply set the desired padding in xx dp on each side so it get centered where you want it. – Rawa Jul 22 '14 at 11:31
  • If you don't know what dp is you should read up on it. It is in the very core of GUI design for android: http://developer.android.com/guide/practices/screens_support.html This link helps your produce iamges and icons for different screensizes: http://romannurik.github.io/AndroidAssetStudio/ – Rawa Jul 22 '14 at 11:34
  • I tried using "dp" values as you suggested, but that gives me a fixed size in real world. What I mean is, if I use a phone, the arrows should be smaller, but when I use a tablet they should be bigger. This isn't happening if I use dp, they just look the same size. – user3785125 Jul 22 '14 at 12:30
  • If you are using a tablet you normally creature a new layout, please refer to the Android screens support practices – Rawa Jul 22 '14 at 13:02
  • Alright, I forgot about using different layouts. I guess I'll try that. Thanks – user3785125 Jul 22 '14 at 13:20