2016-05-14 62 views
1

时,我有一个顶部和底部的工具栏和它们之间的ImageView的:工具栏出现在布局的顶部使用的RelativeLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mainRelativeLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" > 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_top" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:background="?attr/colorPrimary" 
     android:minHeight="?attr/actionBarSize" /> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_bottom" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:background="?attr/colorPrimary" 
     android:layout_alignParentBottom="true" 
     android:minHeight="?attr/actionBarSize" /> 

    <omar.myapp.app.viewpager.ImageViewPager 
     android:layout_below="@id/toolbar_top" 
     android:layout_above="@id/toolbar_bottom" 
     android:id="@+id/mainViewPager" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     /> 

</RelativeLayout> 

的问题是,底部工具栏出现在ViewPager的顶部:

enter image description here

图像正确位于顶部工具栏下方,但出现在底部工具栏后面。

有谁知道为什么图像会在底部的工具栏后面而不是在它的上面?

回答

1

躲在视图相对框架布局只是做。

使用线性布局是解决你的问题....

对您的编辑XML的样子...此代码的

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mainRelativeLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_top" 
     android:layout_height="50dp" 
     android:layout_width="match_parent" 
     android:background="?attr/colorPrimary" 
     android:minHeight="?attr/actionBarSize" /> 

    <omar.myapp.app.viewpager.ImageViewPager 
     android:id="@+id/mainViewPager" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:src="@drawable/splash" 
     android:scaleType="fitXY" 
     android:layout_weight="1" 
     /> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_bottom" 
     android:layout_height="50dp" 
     android:layout_width="match_parent" 
     android:background="?attr/colorPrimary" 
     android:minHeight="?attr/actionBarSize" /> 

</LinearLayout> 

输出: - enter image description here

享受编码。 ...........

+0

不幸的是,这并没有解决问题:/ – expGuy

+0

你想要两个工具栏顶部? – sushildlh

+0

不,我想要它们之间的图像视图,而不是在底部工具栏后面 – expGuy