0

我正在开发 Android ViewPager。我编写了可以创建 ViewPager 的代码以及另一个具有一些控件的布局。我想先展示我的其他控件。然后我想显示视图页(有标签)。

问题是:它首先显示视图页面布局(relativeLayoutVP),然后我的其他控件布局(relativeLayoutControl)显示在 relativeLayoutVP 上。像这样。

下面是我的xml代码。1 年前已经讨论过这个问题(RelativeLayout 下的 Android viewpager),但没有解决方案。因此,我在这里再次重复。为重复的问题道歉。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fa6a6a" >

<RelativeLayout
    android:id="@+id/relativeLayoutVP"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true">

    <android.support.v4.view.ViewPager
        android:id="@+id/vp_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </android.support.v4.view.ViewPager>
</RelativeLayout>

<RelativeLayout
    android:id="@+id/relativeLayoutControl"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#171717" >

    <ImageButton
        android:id="@+id/menu_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="12dp"
        android:background="@drawable/ic_launcher" />

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="7.0mm"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@drawable/ic_launcher" />

    <ToggleButton
        android:id="@+id/button_search"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="12dp"
        android:background="@drawable/ic_launcher"
        android:padding="2dip"
        android:textOff=""
        android:textOn="" />

</RelativeLayout>

4

1 回答 1

0

换个地方就行了。将 relativeLayoutControl RealtiveLayout 设置为第一个孩子,并将 relativeLayoutVP RelativeLayout 设置为第二个孩子,就是这样。希望这会对某人有所帮助,因为问题真的很老:)

于 2017-10-26T13:35:51.257 回答