你能中心RelativeLayout的一个按钮?你能、按钮、中心、RelativeLayout

由网友(∞帞蕥。)分享简介:我想中心的相对布局的一个按钮,这可能吗?我试过的严重性和定位功能,但他们没有做任何事情。I'm trying to center a button in relative layout, is this possible? I've tried the Gravity and Orientation function...

我想中心的相对布局的一个按钮,这可能吗?我试过的严重性和定位功能,但他们没有做任何事情。

I'm trying to center a button in relative layout, is this possible? I've tried the Gravity and Orientation functions but they don't do anything.

推荐答案

尝试

android:layout_centerHorizontal="true"

完全一样,它为我工作:

Exactly like this, it works for me:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#ff0000">

    <Button
        android:id="@+id/btn_mybutton"
        android:layout_height="wrap_content"
        android:layout_width="124dip"
        android:layout_marginTop="5dip"
        android:layout_centerHorizontal="true"/>

</RelativeLayout>
阅读全文

相关推荐

最新文章