Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,806,934 Members 37,710 Now Online
XDA Developers Android and Mobile Development Forum

Need Some help with layout in calculator app

Tip us?
 
umartariq94
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Aug 2014
Default Need Some help with layout in calculator app

i have attached a picture here

1.) how do i set the buttons so that they look uniform throughout different devices (screen size , tablets etc) right now they look different on the emulator and on a device

2.)i also need some help in implementing some code like when i press Shift Button and then press a button it will alternate between functions of that button .. please guide me on how to implement this ?

also is there an easier way to implement a custom grid of buttons rather than using relative layout for all buttons i have looked into gridview but do not know how to customize it ?

please help .. thanks
Attached Thumbnails
Click image for larger version

Name:	dfgdfgd.PNG
Views:	22
Size:	70.0 KB
ID:	2907774  
 
arpitkh96
Old
#2  
arpitkh96's Avatar
Senior Member
Thanks Meter 384
Posts: 1,093
Join Date: Feb 2012
Location: panipat
Make linearlayouts for every row with height wrap and width match. Now for every child button of that linear layout set width as match parent and height wrap_content.and also add another line in all the buttons android:layout_weight="1"
There can be another approach as well. You can use table layout which is easy. You can find guides on Google for it

Sent from my XT1033 using XDA Premium 4 mobile app
The Following User Says Thank You to arpitkh96 For This Useful Post: [ Click to Expand ]
 
SimplicityApks
Old
#3  
SimplicityApks's Avatar
Senior Member
Thanks Meter 327
Posts: 323
Join Date: May 2013
Location: Aachen
Quote:
Originally Posted by arpitkh96 View Post
Make linearlayouts for every row with height wrap and width match. Now for every child button of that linear layout set width as match parent and height wrap_content.and also add another line in all the buttons android:layout_weight="1"
There can be another approach as well. You can use table layout which is easy. You can find guides on Google for it
Agreed, use a TableLayout (containing multiple TableRows. I suggest reading this doc about creating a table.

Quote:
Originally Posted by umartariq94 View Post
1.) how do i set the buttons so that they look uniform throughout different devices (screen size , tablets etc) right now they look different on the emulator and on a device

2.)i also need some help in implementing some code like when i press Shift Button and then press a button it will alternate between functions of that button .. please guide me on how to implement this ?

also is there an easier way to implement a custom grid of buttons rather than using relative layout for all buttons i have looked into gridview but do not know how to customize it ?
A totally different option to consider here would be using a KeyboardView instead! That way you won't have to deal with all the buttons (and I think the shift function might be easier as well). As it happens, I wrote a guide on how to implement such a custom keyboard a while ago . You just have to make the KeyboardView a little larger and delete the part where the back key hides it. Be warned though, this class is highly undocumented and it's not guarenteed everything is working the way it should.
The Following User Says Thank You to SimplicityApks For This Useful Post: [ Click to Expand ]
 
umartariq94
Old
#4  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Aug 2014
Thanks for the replies !
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes