Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 4    Views: 97

Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
05/19/15 02:52 PM (9 years ago)

Android - Menu Buttons size too small on xhdpi screen

I am creating my first Android app and using a lot of menu button plugin screens throughout the app with a grid layout. On an hdpi screen everything looks great and the button sizes are perfect but if I try to run the app on an xhdpi or xxhdpi screen via the emulator the buttons are way to small. I have tried adding images with different pixel sizes in the drawable-xhdpi folder but this had zero effect on the button size shown on the emulator. I also tried to increase the button size on the control panel for large devices and this did increase the size on the xhdpi device but unfortunately it also increased the button sizes on the hdpi device which messed up the layout on this one. I am a complete newbie where Android is concerned and have tried to find a solution but have hit a brick wall and also looked at this post below but couldn't make it work so really need some help to finalize this app. https://www.buzztouch.com/forum/thread.php?tid=A4F6A305B897CD7865119FA&command=isSearching&currentPage=1&topicTitle=button&createdBy=&repliedBy=&minViews=-1&maxViews=-1&minReplies=-1&maxReplies=-1&forumCategory=
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
05/20/15 01:19 AM (9 years ago)
I think I may have found a solution after reading a post from 3 years ago http://www.buzztouch.com/forum/thread.php?tid=F94BFE1BC2C922CF1DCEBFC&command=isSearching&currentPage=1&topicTitle=small%20and%20large%20device%20issues&createdBy=&repliedBy=&minViews=-1&maxViews=-1&minReplies=-1&maxReplies=-1&forumCategory= If I increase the deviceWidth value on the BT_device.java file then my hdpi phone moves from being identified as a large device via the control panel to a small device and the xhdpi phone stays as a large device on the control panel so I can adjust the button sizes and other settings on the control panel without affecting the other device.
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
05/20/15 12:46 PM (9 years ago)
Hi Sherry You can take full control of your button sizes as discussed in the thread below. Basically, you specify the size of the buttons as a percentage of the screen width. http://www.buzztouch.com/forum/thread.php?tid=298A80CD59CEAD0CD5D3053&fid=BC70C36A743CD4FAD95D17F&sortColumn=FT.id&sortUpDown=&currentPage=76 It takes a little bit of work coding the java file, but I can post a working example if that helps.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
05/20/15 05:28 PM (9 years ago)
Thanks for the reply I missed this post somehow even with lots of searcing through the forum. If you can post a working example that would help me a lot and be fantastic.
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
05/21/15 02:52 PM (9 years ago)
The full BT_screen_menuButtons.java can be found here: https://www.dropbox.com/s/e93xbvq3rknbyqg/BT_screen_menuButtons.java?dl=0 To note: This is taken from a BT version 2 Android app, but will hopefully still be relevant. This does mean you can't copy and paste the whole file and expect it to work however. You will have to cherry-pick the relevant code. The key lines of code are between 481 - 571 - the grid layout. However there is earlier code which is required to gain the device width. Notably lines 48, 49, 210 - 239. There are 2 buttons per row in my app, so I have manually set this figure at line 499 You can alter the button sizes and their padding to suit you at lines 510 and 511. The button width has been set to 100/264 (or 38%) and padding to 100/5000 (or 2%). The button margin can be set at line 488.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.