2011-03-28 96 views
0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="200px" 
    android:background="@layout/roundedshape" 
    android:id="@+id/mainLayout"> 

    <Gallery xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/gallery" 
     android:layout_width="fill_parent" 
     android:layout_height="100px" /> 

    <LinearLayout android:gravity="top" 
     android:id="@+id/gallerytext" 
     android:layout_width="match_parent" 
     android:layout_height="50px" 
     android:layout_below="@+id/gallery" 
     android:layout_centerHorizontal="true"> 
     <TextView android:text="TextView" 
      android:id="@+id/taskname" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"></TextView> 
    </LinearLayout> 
    <LinearLayout android:gravity="top" 
     android:layout_width="match_parent" 
     android:layout_height="50px" 
     android:layout_below="@+id/gallerytext" 
     android:layout_centerHorizontal="true" > 
     <Button android:id="@+id/button_left" 
      android:layout_width="27px" 
      android:layout_height="27px"></Button> 
     <Button android:text="Add" 
      android:id="@+id/button_add" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"></Button> 
     <Button android:text="Edit" 
      android:id="@+id/button_edit" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"></Button> 
     <Button android:id="@+id/button_right" 
      android:layout_width="27px" 
      android:layout_height="27px"></Button> 
    </LinearLayout> 
</RelativeLayout> 

编辑基础的Android UI设计问题

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="200px" android:background="@layout/roundedshape"> 

<Gallery xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gallery" 
    android:layout_width="fill_parent" 
    android:layout_height="100px" 
/> 

<TextView android:layout_below="@+id/gallery" android:text="TextView" android:id="@+id/taskname" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 

<Button android:id="@+id/button_left" android:layout_below="@+id/taskname" android:layout_width="27px" android:layout_height="27px" ></Button> 
<Button android:text="Add" android:id="@+id/button_add" android:layout_below="@+id/taskname" android:layout_toRightOf="@+id/button_left" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 
<Button android:text="Edit" android:id="@+id/button_edit" android:layout_below="@+id/taskname" android:layout_toRightOf="@+id/button_add" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 
<Button android:id="@+id/button_right" android:layout_below="@+id/taskname" android:layout_toRightOf="@+id/button_edit" android:layout_width="27px" android:layout_height="27px"></Button> 

当我把它覆盖两个LinerLayoutsRelativeLayout的背景。

我怎样才能让背景颜色和两个LinearLayout在顶部可见?或者我的看法不对?

回答

1

您的布局没有任何问题。如果您将RelativeLayout的背景设置为#FFFFFFFF(白色),那么这正是发生的情况。背景(包括LinearLayouts)变为白色。但LinearLayouts位于RelativeLayout之上 - 您仍然可以看到从LinearLayouts中显示的按钮和任何文本。如果您将LinearLayouts的背景设置为不同的颜色,您会看到这反映在布局中 - 它们实际上位于RelativeLayout之上。

+0

好的......无论如何......我只是重写了它......猜这一个更有效率...... – 2011-03-28 11:46:55