Android - 布局:定位按钮问题

时间:2012-11-06 19:19:26

标签: android android-layout

在我的应用程序布局中,我有一个相对布局,其中包含7个按钮。现在我想在行的开头添加另一个Button(@ + id / IB_Summe)。但是在GraphicalLayout和我的设备上,前两个按钮(@ + id / IB_Summe和@ + id / ImageButton01)被覆盖。他们不是吗?我做错了什么?

my xml-Layout:

<RelativeLayout
 android:id="@+id/Buttonleiste"
 android:layout_width="fill_parent"
 android:layout_height="120px"
 android:layout_alignParentBottom="true"
 android:orientation="horizontal"
 android:gravity="bottom|center_horizontal"
 android:paddingTop="2dp"
 android:paddingBottom="2dp" android:background="@drawable/gradient">

<Button
     android:id="@+id/IB_Summe"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_below="@id/graph"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_marginRight="1dp"
     android:background="@layout/selector_empty_square_on"
     android:gravity="center_horizontal|bottom"
     android:lines="1"
     android:paddingBottom="10dp"
     android:text="@string/summe_symbol"
     android:textColor="@color/my_white"
     android:textSize="30sp" />

    <Button
     android:id="@+id/ImageButton01"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_toRightOf="@id/IB_Summe"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_marginRight="1dp"
     android:background="@layout/selector_empty_square_on"
     android:gravity="center_horizontal|bottom"
     android:lines="1"
     android:paddingBottom="10dp"
     android:text="@string/euro_symbol"
     android:textColor="@color/my_white"
     android:textSize="30sp" />

    <Button
     android:id="@+id/menuDiagram"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_marginLeft="1dp"
     android:layout_marginRight="1dp"
     android:layout_toRightOf="@id/ImageButton01"
     android:background="@layout/selector_empty"
     android:gravity="center_vertical|center_horizontal"
     android:lines="1"
     android:maxHeight="38dp"
     android:text="@string/Hour"
     android:textColor="@color/my_white"
     android:textSize="30sp" />

    <Button
     android:id="@+id/menuExtrasButton"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_marginLeft="1dp"
     android:layout_marginRight="1dp"
     android:layout_toRightOf="@id/menuDiagram"
     android:background="@layout/selector_empty"
     android:gravity="center_vertical|center_horizontal"
     android:lines="1"
     android:maxHeight="38dp"
     android:text="@string/Day"
     android:textColor="@color/my_white"
     android:textSize="30sp" />

   <Button
    android:id="@+id/menuInfo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginLeft="1dp"
    android:layout_marginRight="1dp"
    android:layout_toRightOf="@id/menuExtrasButton"
    android:background="@layout/selector_empty"
    android:gravity="center_vertical|center_horizontal"
    android:lines="1"
    android:maxHeight="38dp"
    android:text="@string/Week"
    android:textColor="@color/my_white"
    android:textSize="30sp" />

   <Button
    android:id="@+id/menuCounter"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginLeft="1dp"
    android:layout_marginRight="1dp"
    android:layout_toRightOf="@id/menuInfo"
    android:background="@layout/selector_empty"
    android:gravity="center_vertical|center_horizontal"
    android:lines="1"
    android:maxHeight="38dp"
    android:text="@string/Month"
    android:textColor="@color/my_white"
    android:textSize="30sp" />

   <Button
    android:id="@+id/menuSetting"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginLeft="1dp"
    android:layout_marginRight="1dp"
    android:layout_toRightOf="@id/menuCounter"
    android:background="@layout/selector_empty"
    android:gravity="center_vertical|center_horizontal"
    android:lines="1"
    android:maxHeight="38dp"
    android:text="@string/Year"
    android:textColor="@color/my_white"
    android:textSize="30sp" />

   <Button
    android:id="@+id/menuTarif"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginLeft="1dp"
    android:layout_marginRight="1dp"
    android:layout_toRightOf="@id/menuSetting"
    android:background="@layout/selector_empty_square"
    android:gravity="bottom|center_horizontal"
    android:paddingBottom="10dp"
    android:lines="1"
    android:maxHeight="38dp"
    android:text="@string/kws_symbol"
    android:textColor="@color/my_white"
    android:textSize="30sp" />

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

在第二个按钮中使用android:layout_toRightOf="@+id/IB_Summe"代替android:layout_toRightOf="@id/IB_Summe"。注意加号。这应该工作