0

所以我正在为我的 android 应用程序处理登录和注册页面,我正在尝试实现这个布局,但我无法让它正常工作。

我正在寻找的所需布局是这样的。

所需的布局

背景图像覆盖整个屏幕,然后在右上角有一个按钮,在中间底部有一个按钮。

但这就是我从实施设计中得到的

当前布局

这就是我在布局文件中写下的

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" android:fitsSystemWindows="true" android:alwaysDrawnWithCache="false"
    android:layout_gravity="center">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:scaleType="center"
        android:layout_alignParentTop="true" android:src="@drawable/nyork2"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="top" >

        <Button
        android:id="@+id/register"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:text="@string/button_register"

        />
     <Button
        android:id="@+id/login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:text="@string/button_login"

        />
    </LinearLayout>





</RelativeLayout>
4

2 回答 2

2

这应该有帮助

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" android:fitsSystemWindows="true" android:alwaysDrawnWithCache="false"
    android:layout_gravity="center">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:scaleType="center"
        android:layout_alignParentTop="true" android:src="@drawable/nyork2"/>
    <Button
            android:id="@+id/register"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:text="@string/button_register" />

    <Button
            android:id="@+id/login"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:text="@string/button_login"/>

</RelativeLayout>
于 2013-07-16T01:54:42.077 回答
0

删除线性布局,以便您可以将按钮放在您想要的位置

于 2013-07-16T01:54:26.487 回答