简体   繁体   English

抽屉布局已覆盖背景

[英]Drawer layout has overridden the background

I have a small but bothering problem. 我有一个小但麻烦的问题。

I have a drawable layout for my sliding menu, but when I put it in my XML, the background is totally untouchable because the drawer has filled and overridden on screen: 我的滑动菜单有一个可绘制的布局,但是当我将其放入XML时,背景是完全不可触摸的,因为抽屉已在屏幕上填充并覆盖:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.astuetz.PagerSlidingTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="30dip"
        android:background="@drawable/background_tabs" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/colors"
        android:layout_below="@+id/tabs"
        android:background="@drawable/antartica8"
        tools:context=".ListViewActivity" />

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="false"
    >

        <!-- Framelayout to display Fragments -->

        <!-- Listview to display slider menu -->
        <ListView
            android:id="@+id/list_slidermenu"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:divider="@color/list_divider"
            android:dividerHeight="1dp"        
            android:listSelector="@drawable/list_selector"
            android:background="@color/list_background" />

    </android.support.v4.widget.DrawerLayout>

    <LinearLayout
        android:id="@+id/colors"
        android:layout_width="match_parent"
        android:layout_height="48dip"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="8dip"
        android:layout_marginLeft="4dip"
        android:layout_marginRight="4dip"
        android:orientation="horizontal" >

        <ImageView
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="#FF666666"
            android:onClick="onColorClicked"
            android:tag="#FF666666" />

        <ImageView
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="#FF96AA39"
            android:onClick="onColorClicked"
            android:tag="#FF96AA39" />

        <ImageView
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="#FFC74B46"
            android:onClick="onColorClicked"
            android:tag="#FFC74B46" />

        <ImageView
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="#FFF4842D"
            android:onClick="onColorClicked"
            android:tag="#FFF4842D" />

        <ImageView
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="#FF3F9FE0"
            android:onClick="onColorClicked"
            android:tag="#FF3F9FE0" />

        <ImageView
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="#FF5161BC"
            android:onClick="onColorClicked"
            android:tag="#FF5161BC" />
    </LinearLayout>
</RelativeLayout>

How can I solve this? 我该如何解决? Is there anything like "always on top" to cast on background? 有没有像“总是在最前面”这样的背景投射?

The Layout for an activity which needs to use the navigation drawer should be like this. 需要使用导航抽屉的活动的布局应如下所示。 The Nav Drawer is showing up on top because you're placing the views in an incorrect order. 导航抽屉显示在顶部,因为您以不正确的顺序放置视图。

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- This is where you'll add views to display in the Activity-->
    <!-- E.g. FrameLayout to display Fragments -->
    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

   <!-- The View that you place at the last is shown in the navigation drawer.
        In this case, the following RelativeLayout will be shown in the 
        navigation drawer. -->
   <RelativeLayout
        android:layout_width="240dp"
        android:layout_height="fill_parent"
        android:layout_gravity="start"
        android:id="@+id/drawer_relative_layout">
        <ListView
            android:id="@+id/left_drawer"
            android:layout_width="240dp"
            android:layout_height="match_parent"/>
   </RelativeLayout>

</android.support.v4.widget.DrawerLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM