菜单被遮挡,如何处理层级关系?

菜单被遮挡,如何处理层级关系?

http://img1.sycdn.imooc.com/climg//5931275b000154e622951510.jpg

如图,下面的菜单栏在图片的下面,如何将下面一条指定显示呢?http://img1.sycdn.imooc.com/climg//592fb24e0001df3e07161251.jpg

正在回答

登陆购买课程后可参与讨论,去登陆

3回答

最外层使用线性布局包裹下面的菜单栏和上面的内容就不会遮盖了。

提问者 sd_单子 2017-06-02 14:16:40
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <android.support.v4.view.ViewPager
        android:id="@+id/vpager_main_header_ad"
        android:layout_width="match_parent"
        android:layout_height="140dp">

    </android.support.v4.view.ViewPager>
   <include
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       layout="@layout/main_search">
   </include>
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@mipmap/nav_header_index"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="100dp"/>
    </RelativeLayout>
    <ScrollView
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/vpager_main_header_ad"
        android:id="@+id/scrollView1">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycleview_main_menu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
           </android.support.v7.widget.RecyclerView>
            <View
                android:id="@+id/gray_line1"
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="#d8dde1"
                android:layout_below="@id/recycleview_main_menu"
                android:layout_margin="20dp">

            </View>
            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycleview_second_menu"
                android:layout_below="@+id/gray_line1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
            </android.support.v7.widget.RecyclerView>
            <View
                android:id="@+id/gray_line2"
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="#d8dde1"
                android:layout_below="@id/recycleview_second_menu"
                android:layout_margin="20dp">
            </View>
            <!--旅游热讯-->
            <LinearLayout
                android:id="@+id/main_tra_hot_info"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/gray_line2"
                android:gravity="center">
                <ImageView
                    android:layout_width="100dp"
                    android:layout_height="30dp"
                    android:src="@mipmap/main_hot_news"/>
                <TextView
                    android:textColor="#000000"
                    android:layout_weight="1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="秋天真的来了,吃火锅就按这个火锅地图走!"/>
            </LinearLayout>
            <!--特价-->
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/main_tra_hot_info"
                android:layout_margin="5dp">
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    >
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="120dp"
                        android:background="@mipmap/main_spread1"
                        android:layout_weight="2"/>
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="120dp"
                        android:background="@mipmap/main_spread2"
                        android:layout_weight="1"
                        android:layout_marginLeft="5dp"/>
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="120dp"
                        android:background="@mipmap/main_spread3"
                        android:layout_weight="1"
                        android:layout_marginLeft="5dp"/>
                </LinearLayout>
                <ImageView
                    android:layout_marginTop="5dp"
                    android:layout_width="match_parent"
                    android:layout_height="120dp"
                    android:background="@mipmap/main_spread4"
                   />
            </LinearLayout>

        </RelativeLayout>


</ScrollView>

</LinearLayout>


提问者 sd_单子 2017-06-02 14:15:40
<?xml version="1.0" encoding="utf-8"?>
    <!--内容-->
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/container_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <!--找到上面代码有问题,正确写法在下面-->
        <!--功能菜单-->
        <LinearLayout
            android:id="@+id/container_menu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="#ffffff"
            android:orientation="horizontal">

            <LinearLayout
                android:id="@+id/menu_main"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/menu_icon_selector" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="首页"
                    android:textColor="#000000" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/menu_find"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/find_icon_selector"
                    android:clickable="false" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="发现"
                    android:textColor="#000000" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/menu_me"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/me_icon_selector" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="我的"
                    android:textColor="#000000" />

            </LinearLayout>
        </LinearLayout>
    </RelativeLayout>
<!--这一块正写法-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.imooc.testend.MainActivity">
    <!--内容-->
    <RelativeLayout
        android:id="@+id/container_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

    </RelativeLayout>

虽然不懂为啥是这样写,不过总算问题解决了

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师