maxsap
maxsap

Reputation: 3001

android layout like this one

I would like to make a layout like the one displayed on the this link. just an image and 2 simple buttons on the button of the screen, I am trying using this code:

<merge xmlns:android="http://schemas.android.com/apk/res/android">

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

    <ImageView android:id="@+id/maxsapImg" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_alignParentTop="true"
        android:scaleType="center" android:src="@drawable/golden_gate">
    </ImageView>

    <RelativeLayout android:id="@+id/InnerRelativeLayout"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">

        <Button android:text="@string/camera" android:id="@+id/camerBtn"
            android:layout_alignParentBottom="true" android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </Button>

        <Button android:text="@string/local" android:id="@+id/localBtn" android:layout_width="wrap_content"
            android:layout_toLeftOf="@+id/camerBtn" android:layout_height="wrap_content">
        </Button>

    </RelativeLayout>

</RelativeLayout></merge>

but no luck so far any ideas?

Upvotes: 0

Views: 203

Answers (2)

NickT
NickT

Reputation: 23873

I added android:orientation="horizontal" to the RelativeLayout tag and changed toLeftOf to android:layout_toRightOf="@+id/camerBtn" in the second button tag

            <RelativeLayout
                    android:id="@+id/InnerRelativeLayout"
                    android:orientation="horizontal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_centerHorizontal="true">
                    <Button
                            android:text="@string/camera"
                            android:id="@+id/camerBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" />
                    <Button
                            android:text="@string/local"
                            android:id="@+id/localBtn"
                            android:layout_width="wrap_content"
                            android:layout_toRightOf="@+id/camerBtn"
                            android:layout_height="wrap_content" />
            </RelativeLayout>

This works for me

Upvotes: 1

Konstantin Burov
Konstantin Burov

Reputation: 69228

<merge xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent" android:layout_height="fill_parent">
    <ImageView android:id="@+id/maxsapImg" android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="center" android:src="@drawable/golden_gate"/>
    <RelativeLayout android:id="@+id/InnerRelativeLayout"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" android:layout_centerHorizontal="true">
        <Button android:text="@string/camera" android:id="@+id/camerBtn"
                android:layout_width="wrap_content" android:layout_height="wrap_content"/>
        <Button android:text="@string/local" android:id="@+id/localBtn"  android:layout_width="wrap_content"
                android:layout_toLeftOf="@+id/camerBtn" android:layout_height="wrap_content"/>
    </RelativeLayout>
</RelativeLayout>
</merge>

Upvotes: 1

Related Questions