I am trying to implement a translucent navigation bar in an app. The layout looks fine before:
The problem occurs when I add the following lines of code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getActivity().getWindow(); // in Activity's onCreate() for instance
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
My layout all of a sudden looks like this:
Note that I am using android:fitsSystemWindows="true" on the textview otherwise it slides under the action bar. Here is a portion of my layout:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:textSize="15sp"
android:id="@+id/missions_summary"
android:text="@string/downloading"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:layout_alignParentRight="true"
android:id="@+id/loading"/>
<View style="@style/Divider_h"
android:layout_below="@id/missions_summary"
android:id="@+id/top_divider"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/top_divider"
android:id="@+id/layout_power"
android:layout_margin="5dp">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/power_users"/>
...and so on
Does anyone know why this is occurring or how to stop it (other than not using translucent navigation bar of course)?