如何设置导航抽屉背景的透明度? [英] How to set transparency of Navigation drawer background?

查看:113
本文介绍了如何设置导航抽屉背景的透明度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够将背景设置为完全透明.似乎以前没有人尝试过.请帮忙.

I need to be able to set the background as completely transparent. Seems no one has tried it before . Please help.

如果我是正确的,我们需要使framelayout backgrund完全透明.但是这样做没有效果.

If Im correct we need to make framelayout backgrund totally transparent . But no effect taking place on doing it.

感谢您的所有回复,但到目前为止,它们似乎都没有起作用.

Thanks for all your reponses , but none ofthem seems to be working so far.

为进一步说明,我需要使列表视图下方的背景透明.

To clarify further , I need to make the background below the listview to be transparent.

也就是说,当抽屉完全打开时,以下活动的部分屏幕可见.它显示为模糊的灰色,可见一些文本.我需要使它完全可见.

That is, when the drawer is opened completely .There is a partial screen from the below activity that is visible. It shows as blurred greyed out with some text visible. I need that to be perfectly visible.

我需要更改活动中的某些主题吗?

Do I need to change some themes in activity?

以下是完整的布局xml

The following is the complete layout xml

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

<RelativeLayout
    android:id="@+id/headerLayout"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@color/headerBlue"
    android:gravity="center_vertical"
    android:orientation="horizontal"
    android:padding="10dp" >

    <Button
        android:id="@+id/drawer_btn"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_alignParentLeft="true"
        android:background="@color/logoutBtnBlue"
        android:onClick="drawerBtnClicked"
        android:padding="5dp"
        android:textColor="@color/white" />

    <TextView
        android:id="@+id/headerText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:gravity="center"
        android:text="PeepApp"
        android:textColor="@color/white"
        android:textSize="25dp" />

    <Button
        android:id="@+id/logout_btn"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_alignParentRight="true"
        android:background="@color/logoutBtnBlue"
        android:onClick="logoutBtnClicked"
        android:padding="5dp"
        android:text="Logout"
        android:textColor="@color/white" />
</RelativeLayout>

<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:alpha="1"  
     android:background="@android:color/transparent"
     >

    <FrameLayout
        android:id="@+id/content_frame"
         android:alpha="0.3"  
         android:background="#00000000"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!--
     android:layout_gravity="start" tells DrawerLayout to treat
     this as a sliding drawer on the left side for left-to-right
     languages and on the right side for right-to-left languages.
     The drawer is given a fixed width in dp and extends the full height of
     the container. A solid background is used for contrast
     with the content view.
    -->

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/logoutBtnBlue"
        android:choiceMode="singleChoice"
        android:divider="@android:color/white"
        android:dividerHeight="1dp" />
</android.support.v4.widget.DrawerLayout>

推荐答案

不确定我是否理解您,我会给您一个机会.让我们来看看.如果我没记错的话,您将看不到抽屉本身.您所看到的是其中的ListView.因此,要使其背景透明,只需设置

Not sure if I understand you, by I'll give it a shot. Let's see. If I am not mistaken, you cannot see the drawer itself. What you see is the ListView inside of it. So in order to set its background transparent all you need to do is set

android:background="@android:color/transparent"

到您的ListView XML.

to your ListView XML.

这将使它完全不可见,但是如果您想要某种颜色的透明度,则可以使用公认的答案此处选择正确的值.

That will make it totally invisible, but if you want transparency with some color you can use accepted answer here to pick the right value.

希望这会有所帮助.

这篇关于如何设置导航抽屉背景的透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆