2013-06-28 70 views
0

我想显示4个图像视图(第2行和第2行)和一些奇怪的原因,底部行的2图像视图没有显示出来。这是我的代码,希望有人能帮助我。图像视图不出现

<?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> 
+0

清除项目,如果仍然没有显示然后重新启动Eclipse,将XML是正确的.. – MohsinSyd

+0

我不知道这是否是问题,但你真的应该只使用'@ + id'格式来*创建一个新的ID。要引用现有的你应该使用'@ id'。例如。 'android:layout_below =“@ id/TopTwoButtons”'http://stackoverflow.com/a/5025971/833647 –

+0

@杰克杰克巨人杀手我也检查了..它是正确的。:) – TheFlash

回答

0

试试这个代码

<?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> 
+0

我试过使用代码,只是将搜索按钮放到应用程序的顶部,并将其与另一个按钮(List)完全取消对齐。我用eclipse中的图形布局添加了一个屏幕截图,使用你给我的代码,希望我们能够解决这个问题,谢谢。 – Jack