[android-developers] Re: layout problem
change the linearlayout to warp_content and put it in a RelativeLayout/Framelayout and use the proper centering field (centerInParent/layout_gravity)
On Sunday, December 23, 2012 3:34:16 AM UTC+2, dashman wrote:
I've got 3 View elements that i'd like to display at the center
of the page - centered vertically and horizontally.
for the life of me - i can't get it to work.
i've tried layout_gravity set to center_vertical - but it does only one element.
maybe i need to group the 3 elements under another layout and then
do a center_vertical on that???
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/hint" />
<TextView
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" >
</TextView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_ horizontal"
android:text="Got it!" />
</LinearLayout>
On Sunday, December 23, 2012 3:34:16 AM UTC+2, dashman wrote:
I've got 3 View elements that i'd like to display at the center
of the page - centered vertically and horizontally.
for the life of me - i can't get it to work.
i've tried layout_gravity set to center_vertical - but it does only one element.
maybe i need to group the 3 elements under another layout and then
do a center_vertical on that???
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/hint" />
<TextView
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" >
</TextView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_ horizontal"
android:text="Got it!" />
</LinearLayout>
On Sunday, December 23, 2012 3:34:16 AM UTC+2, dashman wrote:
I've got 3 View elements that i'd like to display at the center--
of the page - centered vertically and horizontally.
for the life of me - i can't get it to work.
i've tried layout_gravity set to center_vertical - but it does only one element.
maybe i need to group the 3 elements under another layout and then
do a center_vertical on that???
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/hint" />
<TextView
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" >
</TextView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_ horizontal"
android:text="Got it!" />
</LinearLayout>
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home