[android-developers] Re: idiot's guide to using layout:gravity?

2009-11-02 Thread Tim


On Nov 2, 1:06 am, Emmanuel emmanuel.ast...@gmail.com wrote:
 You can't have two different gravity in the same layout, so you can't
 do it a linear Layout, without introducing a new level in the
 hierarchy.

 I made an entry in my blog on this subject 
 :http://androidblogger.blogspot.com/2009/08/tutorial-how-to-have-two-b...


I guess you could use two FrameLayouts in a LinearLayout too to be
slightly more efficient. Any I wouldn't say 'idiot's guide' - the
documentation on gravity, fill_parent/wrap_content etc. is pretty
scant.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: idiot's guide to using layout:gravity?

2009-11-01 Thread Dexter#39;s Brain
RelativeLayouts are easy to use once you are comfortable with them. If
you still want to use LinearLayout, this will solve your problem.

LinearLayout
android:orientation=horizontal
android:layout_width=fill_parent
android:layout_height=wrap_content

LinearLayout
android:orientation=horizontal
android:layout_width=fill_parent
android:layout_height=wrap_content
   android:layout_gravity=left

Button
android:id=@+id/auth_login_button
android:layout_height=50dip
android:layout_width=100dip
android:text=@string/auth_login_label
android:textColor=#ff
android:background=#ff
android:textStyle=bold
/
/LinearLayout

LinearLayout
android:orientation=horizontal
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_gravity=right

Button
android:id=@+id/auth_signup_button
android:layout_height=50dip
android:layout_width=100dip
android:text=@string/auth_signup_label
android:textColor=#ff
android:background=#ff
android:textStyle=bold
/
/LinearLayout
/LinearLayout


But if you use this, the UI Hierarchy will be very complex. As Mark
suggested, it is better to use a relative layout.

Dexter
http://tech-droid.blogspot.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: idiot's guide to using layout:gravity?

2009-11-01 Thread Emmanuel
You can't have two different gravity in the same layout, so you can't
do it a linear Layout, without introducing a new level in the
hierarchy.

I made an entry in my blog on this subject :
http://androidblogger.blogspot.com/2009/08/tutorial-how-to-have-two-buttons-on.html

Hope it helps,

Emmanuel

On Oct 30, 12:36 am, Jason Proctor jason.android.li...@gmail.com
wrote:
 i have a linear layout with two buttons. i'd like the first to be at
 the left edge of the container, and the right to be at the... right
 edge. layout gravity is advertised to do this but i don't seem to be
 able to influence placement with it at all. i've had the gravity
 affect the text inside the buttons, which is a bit weird, but it no
 longer seems to do that...

 LinearLayout
         android:orientation=horizontal
         android:layout_width=fill_parent
         android:layout_height=wrap_content
         
         Button
                 android:id=@+id/auth_login_button
                 android:layout_height=50dip
                 android:layout_width=100dip
                 android:layout_gravity=left
                 android:text=@string/auth_login_label
                 android:textColor=#ff
                 android:background=#ff
                 android:textStyle=bold
         /

         Button
                 android:id=@+id/auth_signup_button
                 android:layout_height=50dip
                 android:layout_width=100dip
                 android:layout_gravity=right
                 android:text=@string/auth_signup_label
                 android:textColor=#ff
                 android:background=#ff
                 android:textStyle=bold
         /
 /LinearLayout

 --
 jason.vp.engineering.particle

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: idiot's guide to using layout:gravity?

2009-10-29 Thread Mark Murphy

Jason Proctor wrote:
 i have a linear layout with two buttons. i'd like the first to be at 
 the left edge of the container, and the right to be at the... right 
 edge. layout gravity is advertised to do this but i don't seem to be 
 able to influence placement with it at all. i've had the gravity 
 affect the text inside the buttons, which is a bit weird, but it no 
 longer seems to do that...
 
 
 LinearLayout
   android:orientation=horizontal
   android:layout_width=fill_parent
   android:layout_height=wrap_content
   
   Button
   android:id=@+id/auth_login_button
   android:layout_height=50dip
   android:layout_width=100dip
   android:layout_gravity=left
   android:text=@string/auth_login_label
   android:textColor=#ff
   android:background=#ff
   android:textStyle=bold
   /
 
   Button
   android:id=@+id/auth_signup_button
   android:layout_height=50dip
   android:layout_width=100dip
   android:layout_gravity=right
   android:text=@string/auth_signup_label
   android:textColor=#ff
   android:background=#ff
   android:textStyle=bold
   /
 /LinearLayout
 

Switch to RelativeLayout and anchor your buttons to the parent edges.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 1.0 In Print!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---