5

Have upgraded app to use Material Design - Theme.AppCompat.Light.NoActionBar, Toolbar instead of ActionBar etc..

And have a problem. Bottom content become to be hidden under soft NavigationBar (see picture below) on devices with APi >= 21

Have found solution to fix this:

in values-v21/styles.xml

<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
        ...
        <item name="colorPrimaryDark">@color/green</item>
        <item name="android:windowDrawsSystemBarBackgrounds">false</item>
</styles>

if option <item name="android:windowDrawsSystemBarBackgrounds">false</item> - bottom content is visible, but statusbar become completely black. I cant change color to colorPrimaryDark (green in my case)

if option <item name="android:windowDrawsSystemBarBackgrounds">true</item> - bottom content is invisible, and statusbar is green, as expected.

I want to have statusbar colored(green) and visible bottom content.. Probably, issue is with toolbar. Is it pushes content down?

Any suggestions?

<item name="android:windowDrawsSystemBarBackgrounds">true</item>

<item name="android:windowDrawsSystemBarBackgrounds">false</item>

UPDATE:

As suggested @azizbekian, I've replaced container for fragmets to CoordinatorLayout(before FrameLayout) and applied android:fitsSystemWindows="true" In this case bottom panel is visible, but not at the bottom.. Goal is to keep buttons athe bottom...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_height="match_parent"
              android:layout_width="match_parent"
              android:orientation="vertical">
    <include
        layout="@layout/toolbar"/>

        <!-- The main content view -->
        <android.support.design.widget.CoordinatorLayout
                android:id="@+id/content"
            android:fitsSystemWindows="true"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
</LinearLayout>

layout of the screen:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:orientation="vertical"
        xmlns:android="http://schemas.android.com/apk/res/android">
    <FocusableScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:id="@+id/order_editor_layout"
        android:fillViewport="true">

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

            <include
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                layout="@layout/o_e_content" 
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentLeft="true"/>
        </RelativeLayout>
    </FocusableScrollView>
    <include
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            layout="@layout/oe_bottom_pane"/>
</LinearLayout>

Here is result:

UPDATE#2

Activity Layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/my_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:elevation="4dp"
        android:theme="@style/ActionBarTheme"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <!-- The main content view -->
        <FrameLayout
                android:id="@+id/content"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
</android.support.design.widget.CoordinatorLayout>

Replaced LinearLayour with CoordinatorLayout as root for activity. As root element for content I've keep FrameLayout. Applied android:fitsSystemWindows="true" to CoordinatorLayout. This way, all content was slightly moved up and part of placed below the toolbar(you can see on image below - top elements are circle with + and - symbold. But on previous images there are text on the top.) Regarding bottom elements (buttons panel) - still placed below navigation bar but also slightly moved up. I've marked android:background="@color/red" to easier recognize position of this panel.

Seems, we are on the right way. All we need - to resolve problem - why content moved below the toolbar.. If tolbar will be top ui elemnt, buttons will be visible..

vsvydenko
  • 729
  • 1
  • 9
  • 22
  • write this property in your layout.xml parent layout. android:fitsSystemWindows="true" – Andy Developer Aug 11 '17 at 12:16
  • 1
    Have tried this approach, but it was not helped me.. Now, in some places bottom content is visible, in some - not. ANd button are placed not at the bottom of the screen. I've updated my question. – vsvydenko Aug 11 '17 at 17:03

1 Answers1

2

Apply android:fitsSystemWindows="true" to your root view.

See this post for detailed explanation.

azizbekian
  • 60,783
  • 13
  • 169
  • 249
  • at the top I have an Activity. With FrameLayout as container for fragments: Acording to your post - all I need - is to change FrameLayout to some materialish layout like CoordinatorLayout and apply fitsSystemWindows option.. I'm right? – vsvydenko Aug 11 '17 at 12:48
  • 1
    Yes, and `android:windowDrawsSystemBarBackgrounds` set to `true`. – azizbekian Aug 11 '17 at 13:24
  • I'm not sure that CoordinatorLayout is good practice to use as a container for fragments. Mostly it is FrameLayout.. – vsvydenko Aug 11 '17 at 14:31
  • It depends on your use case. – azizbekian Aug 11 '17 at 14:32
  • Have replaced container layout with Coordinator. Bottom buttons are visible, but not at the bottom of the screen.. Is it a CoordinatorLayout feature? I've added xml in question. Could you please check? – vsvydenko Aug 11 '17 at 15:35
  • @vsvydenko, remove `LinearLayout`. Make `CoordinatorLayout` the root of your view hierarchy. Currently, `fitsSystemWindows` won't take effect, because as mentioned in the post `LinearLayout` won't dispatch system inset to `CoordinatorLayout`. – azizbekian Aug 14 '17 at 05:38
  • Updated my question. Added CoordinatorLayout as top element. Some of my content moved below the toolbar. Seems we need to fix this, and bottom buttons panel will be visible. Do you have any thoughts regarding this? – vsvydenko Aug 14 '17 at 10:17
  • Post your project at github, I'll have a look. – azizbekian Aug 14 '17 at 10:26
  • I am also suffering from this problem, did you manage to figure it out @vsvydenko? – shredder Mar 15 '18 at 09:01