Java RelativeLayout下的Android viewpager
我正在处理ViewPager。我写的代码可以创建ViewPager,我还有一些java类,但我希望我的ViewPager必须在布局下面。 这是我的xml代码Java RelativeLayout下的Android viewpager,java,android,android-viewpager,android-relativelayout,Java,Android,Android Viewpager,Android Relativelayout,我正在处理ViewPager。我写的代码可以创建ViewPager,我还有一些java类,但我希望我的ViewPager必须在布局下面。 这是我的xml代码 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="
<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/relativeLayout1"
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>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayout1" >
<android.support.v4.view.ViewPager
android:id="@+id/vp_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/relativeLayout1" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
我希望我的viewpager(actionBar)应呈现在布局下方尝试以下操作:
<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: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/relativeLayout1"
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>
</RelativeLayout>
也别忘了清理你的项目。希望对你有所帮助看看吧,
它将帮助你
<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/relativeLayout1"
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>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayout1" >
<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>
如果您想在所有内容下呈现它,为什么要在所有其他布局之后安装它?!你能发帖吗,你现在怎么样了?我不明白你的意思。你是什么意思。在我的xml文件中,我有两个不同的RelativeLayout和,并且我的ViewPager不是第二个RelativeLayout,我希望第二个RelativeLayout应该是第一个RelativeLayout的bellow,但是。当我运行project时,第一个RelativeLayout是RelativeLayout的bellow(不同的结果:()这是一个结果检查我下面的答案,让我知道你得到了什么谢谢,但什么都没有发生。结果是一样的(请看我的图片这是一个屏幕截图)我现在无法在office打开链接,抱歉,我稍后会检查确定删除android:layout_Lower=“@+id/relativeLayout1”然后重试,我编辑了上面的代码OK remove android:layout_below=“@+id/relativeLayout1”并重试,我编辑了上面的代码谢谢我使用了你的代码,但结果是相同的。nothink happenederror是。relativelayout无法转换为android.support.v4.view.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/relativeLayout1"
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>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayout1" >
<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>