• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

How to fit two Button views in single cell in Android's GridLayout?

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this super complicated design in the attachment. I would like to fit left and right parenthesis in single cell (row 1, col 1) so they occupy 1/2 of the cell for each button. I have following xml

Calc-design.png
[Thumbnail for Calc-design.png]
 
Saloon Keeper
Posts: 6703
161
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You couLd use a TableLayout (or some other layout like LinearLayout) inside of that grid cell.
 
Mike Gosling
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with that one as well. No way to get it nearly as I want.

 
Tim Moores
Saloon Keeper
Posts: 6703
161
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried with that one as well. No way to get it nearly as I want.


What does that mean, exactly? What was the result, and how did that differ from what you wanted?
 
Mike Gosling
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that that ( and ) keep using too much space and eventually the / sign gets pushed out from the screen. I don't know how to make ( and ) take 1/2 of their original width, so I could accommodate their width in cell.

Turns out, according to some SO posts, that GridLayout is not meant for this kind of action. As Tim suggested, I also tried with Linear Layout. I'm getting similar results.



Again, as with TableLayout, both ( and ) takes too much of space. They in total should take as much now one button takes place. Division sign gets push out.

Should I try to do this design in LinearLayout (horizonatl) only?
Screenshot_2.png
[Thumbnail for Screenshot_2.png]
 
Mike Gosling
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I give up on GridLayout. I actually used this guy's tutorila on Linear Layout. Super cool idea to nest linear layouts.

reply
    Bookmark Topic Watch Topic
  • New Topic