Michael Nana
Michael Nana

Reputation: 1987

Layout issues with android

So I'm working on the Login and Registration page for my android app and I'm trying to get this layout implemented but I can't get it to work properly.

The desired layout I'm looking for is this.

desired layout

The background image covers the whole screen and then there is a button at the top right and a button at the middle bottom.

But this is what I got from implementing the design

current layout

and this is what I wrote down in the layout file

<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>

Upvotes: 0

Views: 69

Answers (2)

Carp Fisherman
Carp Fisherman

Reputation: 141

This should help

    <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>

Upvotes: 2

Giant
Giant

Reputation: 1649

remove the linear layout so you can put the button where you want them to be

Upvotes: 0

Related Questions