Naga
Naga

Reputation: 2021

Button is not getting displayed in Relative layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/main_screen_image"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="@drawable/facebook_login_button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/button1"
        android:layout_centerHorizontal="true"
        android:background="@drawable/have_a_look_text_image" />

</RelativeLayout>

Can any body please tell me why button2 is not getting displayed, I am really not able to figure it out

Upvotes: 1

Views: 1970

Answers (1)

Alexander
Alexander

Reputation: 48232

Because button1 is aligned to the parent's bottom

android:layout_alignParentBottom="true"

and button2 is requested to be below button1

android:layout_below="@id/button1"

so button2 is not visible

Upvotes: 1

Related Questions