Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使Android操作栏透明_Android_Android Actionbar_Android Appcompat - Fatal编程技术网

使Android操作栏透明

使Android操作栏透明,android,android-actionbar,android-appcompat,Android,Android Actionbar,Android Appcompat,我正在尝试使我的AppCompatActivity的操作栏透明。我正在(从)找东西 我试过这样做: getWindow().setFlags(WindowManager.LayoutParams.FLAG_半透明_导航,WindowManager.LayoutParams.FLAG_半透明_导航) 但它所做的唯一一件事是将视图置于操作栏后面 如何才能使文本和导航抽屉按钮成为其上唯一可见的内容 编辑: 这是我的xml布局 <?xml version="1.0" encoding="utf-8

我正在尝试使我的AppCompatActivity的操作栏透明。我正在(从)找东西

我试过这样做:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_半透明_导航,WindowManager.LayoutParams.FLAG_半透明_导航)

但它所做的唯一一件事是将视图置于操作栏后面

如何才能使文本和导航抽屉按钮成为其上唯一可见的内容

编辑: 这是我的xml布局

<?xml version="1.0" encoding="utf-8"?>

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

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <RelativeLayout
            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:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            tools:context="my.package.name"
            android:id="@+id/relLayout">

            <!-- My views are here -->

        </RelativeLayout>

    </ScrollView>

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

对于未来的读者:

我通过将操作栏的颜色设置为完全透明的颜色,
color.transparent
。 这是我的密码:

 getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

 getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

您是否尝试过设置ActionBar的背景色?请显示您的xml布局。试试这个@jonas.koeritz我不确定如何使颜色不不透明。我在xml布局中进行了编辑。@RuwankaMadhushan你做到了!我把它和我以前的代码结合起来,使用了颜色#00ffffff,它做的一切都符合预期。谢谢尝试一个ARGB值,如“00000000”表示完全透明。@AntónioPaulo不,它会使应用程序崩溃,但“00000000”工作我今天使用它,我需要一个按钮来具有透明背景。@AntónioPaulo我刚刚尝试过,它抛出了一个“无效颜色”例外,可能在按钮中工作,因为它不提供颜色。无论如何,你自己找到答案做得很好。@srv_sud我可以在发布两天后接受我自己的答案