0

I wanna make the Navigation Bar totally transparent and the status bar either transparent or translucent !

so I added these line inside v21/styles

<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>

and this inside the onCreate

   getWindow().getDecorView().setSystemUiVisibility(
    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
    View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

and this in the root layout

android:fitsSystemWindows="true"

The navigation bar shows transparent successfully, but the status bar overlapped..! I tried to move the last line in every Layout in the xml but no luck.. sometimes it stopped overlapping but the nav bar no longer stays transparent..! Any help?

enter image description here enter image description here

The full XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:autofit="http://schemas.android.com/apk/res-auto"
  xmlns:custom="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/view"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#2d2b30">


<LinearLayout
 android:orientation="vertical"
 android:layout_width="match_parent"
 android:layout_height="wrap_content">


<android.support.v7.widget.Toolbar
  android:id="@+id/toolbar"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@color/colorToolbar"
  app:titleTextColor="@color/white"/>


<FrameLayout

  android:layout_width="match_parent"
  android:layout_height="wrap_content">

  <ImageView
    android:id="@+id/decoratoin"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:alpha="0.017"
    android:elevation="5dp"
    android:scaleType="center"
    android:src="@drawable/decoration0"/>


  <!-- The Linearlayout with id="rootView"  is the one that contains the major views  -->

  <LinearLayout
    android:id="@+id/rootView"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView

      android:id="@+id/card"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="10dp"
      android:padding="5dp"
      app:cardBackgroundColor="#da2e2c30"
      app:cardCornerRadius="2dp"
      app:cardElevation="5dp">

      <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <me.grantland.widget.AutofitTextView
          android:id="@+id/txt"
          android:layout_width="match_parent"
          android:layout_height="95dp"
          android:layout_margin="2dp"
          android:padding="5dp"
          android:maxLines="4"
          android:text="ooooooooooo"
          android:textColor="#ffff"
          android:textSize="20sp"
          autofit:minTextSize="12sp"/>

        <ImageView
          android:id="@+id/swipe_arrow"
          android:layout_width="40dp"
          android:layout_height="40dp"
          android:layout_gravity="center_vertical|end"
          android:alpha="0.1"
          android:src="@drawable/swipe_icon"/>

      </FrameLayout>

    </android.support.v7.widget.CardView>

    <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginStart="15dp"
      android:layout_marginEnd="15dp"
      android:layout_gravity="center"
      android:orientation="horizontal">

      <ImageView
        android:id="@+id/reset"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginStart="15dp"
        android:layout_marginEnd="15dp"
        android:layout_gravity="center_horizontal|center_vertical"
        android:padding="2dp"
        android:clickable="true"
        android:hapticFeedbackEnabled="true"
        android:src="@mipmap/reset"/>

      <TextView
        android:id="@+id/btn_edit"

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginStart="15dp"
        android:layout_marginEnd="15dp"
        android:layout_gravity="center_horizontal|center_vertical"
        android:padding="2dp"
        android:background="@mipmap/nums_max"
        android:clickable="true"
        android:elevation="10dp"
        android:hapticFeedbackEnabled="true"/>

      <TextView
        android:id="@+id/btn_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginStart="15dp"
        android:layout_marginEnd="15dp"
        android:layout_gravity="center_horizontal|center_vertical"
        android:padding="1dp"
        android:background="@mipmap/azkar_list"
        android:clickable="true"
        android:elevation="10dp"
        android:hapticFeedbackEnabled="true"/>

    </LinearLayout>

    <FrameLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content">


      <com.github.lzyzsd.circleprogress.ArcProgress
        android:id="@+id/arc_progress"
        android:layout_width="220dp"
        android:layout_height="220dp"
        android:layout_marginTop="30dp"
        android:layout_marginStart="20dp"
        android:layout_marginEnd="20dp"
        android:layout_marginLeft="50dp"
        android:layout_gravity="center_horizontal"
        android:background="#2d2b30"
        custom:arc_bottom_text=" "
        custom:arc_bottom_text_size="35dp"
        custom:arc_finished_color="@color/colorAccent"
        custom:arc_progress="55"
        custom:arc_stroke_width="20dp"
        custom:arc_suffix_text=" "
        custom:arc_text_color="#84e43b"
        custom:arc_text_size="45dp"
        custom:arc_unfinished_color="#2cf2f2f1"/>

      <TextView
        android:id="@+id/check"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|bottom"
        android:background="@drawable/check"
        android:visibility="gone"/>


    </FrameLayout>

  </LinearLayout>

 </FrameLayout>


</LinearLayout>

Alaa AbuZarifa
  • 1,171
  • 20
  • 39
  • 1
    See [this](https://stackoverflow.com/a/43848091/1083957) answer. – azizbekian May 25 '17 at 06:32
  • @azizbekian well, after I removed `android:fitsSystemWindows="true"` from my xml and then added `OnApplyWindowInsetsListener` method instead for my toolbar as you explained in the answer, It worked :D !! I read in the answer why this way works, but couldn't exactly understand what you meant by **(...with this the root layout would consume WindowInsets..)** can explain more if you can..! – Alaa AbuZarifa May 25 '17 at 07:29
  • Make you have read [this post at medium](https://medium.com/@azizbekian/windowinsets-24e241d4afb9) where I've tried to do my best describing how it works. – azizbekian May 25 '17 at 07:33
  • great..will do now, thanks! – Alaa AbuZarifa May 25 '17 at 07:58

2 Answers2

0

Did you try using android:layout_below and layout_above?

Yousef
  • 307
  • 2
  • 14
0

Thanks to @azizbekian, I removed android:fitsSystemWindows="true" from my xml and then added this listener to my toolbar..! It worked :D

  toolbar.setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
  @Override
  public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
    ((MarginLayoutParams) v.getLayoutParams()).topMargin =
        insets.getSystemWindowInsetTop();
    return insets.consumeSystemWindowInsets();
  }
});

More details about this can be found on his medium article.

Alaa AbuZarifa
  • 1,171
  • 20
  • 39