Some elements of the fragment are hidden under the action bar

I am studying an Android developer, and my question can be very simple. I got stuck at the bottom and asked you to help

Description

I use the android default "navigation box" to implement a small project. I created a fragment, and when the user selects an option from the navigation box, the fragment opens.

Problem encountered

When a fragment opens, part of the fragment and the action bar are cropped. Image below enter image description here

code

fragment

<LinearLayout 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:fitsSystemWindows="true" android:clipToPadding="false" android:orientation="vertical" android:background="#ffffff" android:layout_weight="120" tools:context="test.navigationdrawcheck.RateCalculator"> <EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:ems="12" android:gravity="center" android:layout_weight="10" android:hint="text 1" android:textColorHint="@color/colorDivider" android:id="@+id/editText" android:layout_gravity="center_horizontal" /> <EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 2" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText1" android:layout_gravity="center_horizontal" /> <EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 3" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText3" android:layout_gravity="center_horizontal" /> <EditText android:layout_width="wrap_content" android:layout_height="5dp" android:inputType="number" android:hint="text 4" android:textColorHint="@color/colorDivider" android:ems="12" android:gravity="center" android:layout_weight="10" android:id="@+id/editText4" android:layout_gravity="center_horizontal" /> <TextView android:layout_width="wrap_content" android:layout_height="15dp" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Total " android:textColor="@color/colorDivider" android:layout_weight="10" android:textStyle="bold" android:gravity="center_vertical" android:id="@+id/textView" android:layout_gravity="center_horizontal" /> <Button android:layout_width="match_parent" android:layout_height="10dp" android:inputType="number" android:ems="15" android:gravity="center" android:layout_weight="5" android:id="@+id/editText6" android:text="Submit" android:textSize="20sp" android:textColor="@color/colorWhite" android:background="@color/colorPrimary" android:layout_gravity="center_horizontal" /> 

Application barcode

 <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="test.navigationdrawcheck.MainActivity"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:elevation="4dp" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:fitsSystemWindows="true" app:popupTheme="@style/AppTheme.PopupOverlay"/> </android.support.design.widget.AppBarLayout> <FrameLayout android:id="@+id/framecheck" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_dialog_email" /> </android.support.design.widget.CoordinatorLayout> 

The actual conclusion I'm looking for

Below is my actual xml snippet. When I combine it with a portable box, it cannot be trimmed , and fragments should be displayed correctly

enter image description here

What have i tried so far

I tried adding this android:windowActionBarOverlay=false to my styles.xml but no luck

Request your suggestions

+6
source share
1 answer

This may come from the default behavior of CoordinatorLayout. I also suggest that you add your fragments to frameLayout frameCheck. In the layout of your application barcode, replace

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

from:

 <FrameLayout android:id="@+id/framecheck" app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior" android:layout_width="match_parent" android:layout_height="match_parent" /> 
+18
source

All Articles