抽屉布局覆盖背景抽屉、布局、背景

2023-09-07 01:31:59 作者:心悦君兮

我有一个小而困扰的问题。

I have a small but bothering problem.

我有一个绘制布局我的滑动菜单,但是当我把它放在我的XML,背景完全是碰不得的,因为抽屉填补和覆盖在屏幕上:

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:

<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>