Try to set the attr of the LnearLayout with
android:gravity="center_vertical"

On 2月4日, 上午4时34分, kknight <kknight2...@gmail.com> wrote:
> I have a LinearLayout, which only contains one button. I want this
> button to be centered vertically and aligned to the right. I tried
> many ways, but I couldn't make this button centered vertically. It is
> always aligned to the top. I also tried to put a button in
> RelativeLayout, the button can not be centered vertically either.
>
> The XML is as below. Is there anything wrong with this layout? Thanks.
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     android:orientation="vertical" android:layout_width="fill_parent"
>     android:layout_height="wrap_content" android:background="#E8E3E4">
>     <Button
>         android:layout_width="wrap_content"
> android:layout_height="wrap_content"
>         android:text="More" android:layout_gravity="right|
> center_vertical" />
> </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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to