This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Android and the fly likes how to put layout in middle of the screen? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "how to put layout in middle of the screen?" Watch "how to put layout in middle of the screen?" New topic
Author

how to put layout in middle of the screen?

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 188
Hi All,

How can I cause to the LinearLayout to be placed in the middle of the screen and not at the top ?

Thanks




Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

try android:gravity="center_vertical" on the LinearLayout...

[Edit] Since your buttons don't fill up the horizontal space, you'll need to align to center both vertically and horizontally. Try this: android:gravity="center|center_vertical"


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 188
this is working for me ...



Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to put layout in middle of the screen?
 
Similar Threads
Layout question.
how to call button inside a slidingDrawer
ListView textColor
Need Help on the scrolling Bar in Android?
odd framelayout/surfaceview problem