4

I'm trying to make my AppCompatActivity's Action Bar transparent. I'm looking for something like this (from this app).

I've tried doing this:

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

But the only thing it does is making views go behind the action bar.

What can I do so that the text and the navigation drawer button are the only visible things on it?

Edit: Here is my xml layout

<?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>
srv_sud
  • 647
  • 1
  • 9
  • 26
marti201
  • 376
  • 2
  • 13

1 Answers1

11

For future readers:

I did it by setting the color of the action bar to a fully transparent color, Color.TRANSPARENT. Here is my code:

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

 getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
marti201
  • 376
  • 2
  • 13