片段项的一部分隐藏在操作栏下 [英] Part of Fragment items hides under Action bar
问题描述
我正在学习android dev,我的问题可能很简单.我被困在下面并要求您的帮助
I am learning android dev and my question might be very simple. I am stuck at the below part and requesting your help
说明
我正在使用android的默认导航抽屉"活动来实施一个小项目.我已经创建了一个片段,当用户从导航"抽屉中选择一个选项时,该片段将打开.
I am using the android's default "Navigation Drawer" activity to implement a small project. I have created a fragment and when user selects an option from Navigation drawer, the fragment opens.
面临的问题
打开片段时,片段的一部分&动作栏被剪切.下图
When the fragment opens, part of the fragment & action bar is clipped. Image below
代码
片段布局
<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" />
应用条形码
<?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>
我正在寻找的实际输出
下面是我的实际片段布局xml.当我将其与导航抽屉合并时,不应对其进行剪切,并且碎片项目应正确显示
Below is my actual fragment layout xml. When i merge it with Navigation drawer it should not be clipped and fragment items should be displayed correctly
到目前为止我尝试过的事情
我尝试在我的styles.xml中添加此 android:windowActionBarOverlay = false
,但是没有运气
I tried adding this android:windowActionBarOverlay=false
in my styles.xml but no luck
请求您的建议
推荐答案
这可能来自CoordinatorLayout的默认行为.我还假设您将片段添加到frameLayout frameCheck中.在您的应用条形码布局中,替换
This might come from the default behaviour of the CoordinatorLayout. I also assume that you add your fragments in the frameLayout frameCheck. In your app bar code layout, replace
<FrameLayout
android:id="@+id/framecheck"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
使用:
<FrameLayout
android:id="@+id/framecheck"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
android:layout_width="match_parent"
android:layout_height="match_parent" />
这篇关于片段项的一部分隐藏在操作栏下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!