0

I want to display 4 image views (2 on the top row and 2 on the second row) and for some weird reason, the 2 image views on the bottom row are not showing up. Here's my code, hopefully someone could help me out.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<RelativeLayout
    android:id="@+id/TopTwoButtons"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background_meduim"
    android:gravity="center_horizontal" >

    <ImageView
        android:id="@+id/ListButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="35dp"
        android:layout_marginTop="130dp"
        android:src="@drawable/list_button_medium" />

    <ImageView
        android:id="@+id/SearchButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignTop="@+id/ListButton"
        android:layout_marginLeft="35dp"
        android:src="@drawable/search_button_medium" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/BottomTwoButtons"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/TopTwoButtons"
    android:background="@drawable/background_meduim"
    android:gravity="center_horizontal" >

    <ImageView
        android:id="@+id/InfoButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerInParent="true"
        android:layout_marginLeft="35dp"
        android:src="@drawable/info_button_meduim" />

    <ImageView
        android:id="@+id/PopularButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerInParent="true"
        android:layout_marginRight="35dp"
        android:src="@drawable/popular_button_medium" />
</RelativeLayout>

</RelativeLayout>
Jack
  • 11
  • 4
  • Clear project if still not showing then restart your eclipse, your xml is correct.. – MohsinSyd Jun 28 '13 at 10:19
  • I'm not sure if this is the issue but you should really only use the `@+id` format to *create* a new id. To reference an existing you should use `@id`. Eg. `android:layout_below="@id/TopTwoButtons"` http://stackoverflow.com/a/5025971/833647 – Ken Wolf Jun 28 '13 at 10:22
  • @Jack jack the giant slayer i have also checked..it is correct.:) – TheFlash Jun 28 '13 at 10:22

1 Answers1

0

Try this code

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical" >
  <LinearLayout
   android:id="@+id/TopTwoButtons"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:background="@drawable/background_meduim"
   android:orientation="horizontal"
   android:gravity="center_horizontal" >

<ImageView
    android:id="@+id/ListButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="35dp"
    android:layout_marginTop="130dp"
    android:src="@drawable/list_button_medium" />

<ImageView
    android:id="@+id/SearchButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignTop="@+id/ListButton"
    android:layout_marginLeft="35dp"
    android:src="@drawable/search_button_medium" />
  </LinearLayout>
  <LinearLayout
    android:id="@+id/BottomTwoButtons"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background_meduim"
    android:orientation="horizontal"
    android:gravity="center_horizontal" >

<ImageView
    android:id="@+id/InfoButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerInParent="true"
    android:layout_marginLeft="35dp"
    android:src="@drawable/info_button_meduim" />

<ImageView
    android:id="@+id/PopularButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerInParent="true"
    android:layout_marginRight="35dp"
    android:src="@drawable/popular_button_medium" />
  </LinearLayout>
 </LinearLayout> 
Sagar Patil
  • 1,400
  • 15
  • 29
  • I have tried using that code and that just puts the Search button to the top of the app and completely un-aligns it from the other button(List). I've added a screen shot of what it looks like from graphical layout in eclipse using the code you gave me, hopefully we can get this resolved, Thanks. – Jack Jun 28 '13 at 11:07