0

我在一个布局中有一个 ViewFlipper、一个按钮和一个自定义视图。我希望按钮和自定义视图位于 viewflipper 的顶部,以便它们出现在 viewflipper 中包含的每个布局中。但是我现在除了 viewflipper 什么都看不到。怎样才能达到我想要的效果?

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_width="fill_parent"
    android:id="@+id/water_room_layout" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

       <com.example.room.CustomView
        android:id="@+id/customView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
       <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        android:text="Button" 
        android:layout_gravity="center_horizontal|bottom"
       />
    <ViewFlipper android:id="@+id/water_room_flipper"
        android:layout_width="fill_parent" android:layout_height="fill_parent">

        <include layout="@layout/water_room_wall1" android:id="@+id/first" />
        <include layout="@layout/water_room_wall2" android:id="@+id/second" />
        <include layout="@layout/water_room_wall3" android:id="@+id/third" />
        <include layout="@layout/water_room_wall4" android:id="@+id/fourth" />
    </ViewFlipper>

</FrameLayout>
4

1 回答 1

0

使用 aRelativeLayout并重新排列布局中的视图,如下所示:

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

    <ViewFlipper android:id="@+id/water_room_flipper"
                 android:layout_width="fill_parent" android:layout_height="fill_parent">

        <include layout="@layout/water_room_wall1" android:id="@+id/first" />
        <include layout="@layout/water_room_wall2" android:id="@+id/second" />
        <include layout="@layout/water_room_wall3" android:id="@+id/third" />
        <include layout="@layout/water_room_wall4" android:id="@+id/fourth" />
    </ViewFlipper>

    <com.example.room.CustomView
            android:id="@+id/customView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button"
            android:layout_gravity="center_horizontal|bottom"
            />   
</RelativeLayout>
于 2013-10-20T06:30:08.817 回答