Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Need Some help with layout in calculator app

OP umartariq94

22nd August 2014, 04:12 PM   |  #1  
OP Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Aug 2014
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  
22nd August 2014, 06:31 PM   |  #2  
arpitkh96's Avatar
Senior Member
Flag panipat
Thanks Meter: 521
 
1,103 posts
Join Date:Joined: Feb 2012
More
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: [ View ]
22nd August 2014, 07:07 PM   |  #3  
SimplicityApks's Avatar
Senior Member
Flag Aachen
Thanks Meter: 337
 
345 posts
Join Date:Joined: May 2013
More
Quote:
Originally Posted by arpitkh96

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

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: [ View ]
22nd August 2014, 07:18 PM   |  #4  
OP Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Aug 2014
Thanks for the replies !
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes