Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我的操作栏会自动调整大小?_Android_User Interface_Android Support Library_Android Toolbar - Fatal编程技术网

Android 为什么我的操作栏会自动调整大小?

Android 为什么我的操作栏会自动调整大小?,android,user-interface,android-support-library,android-toolbar,Android,User Interface,Android Support Library,Android Toolbar,我正在使用工具栏作为我的支持操作栏在操作栏活动中,该活动由一个查看页面组成,其中有4个选项卡可供滚动,其中我面临一个奇怪的问题。此活动在用户登录后启动。当我第一次登录我的应用程序时,就没有任何问题了。但是,当我第二次启动应用程序时,工具栏最上面的部分被隐藏,然后它开始从顶部滑动,并在系统栏下面的活动布局中进行调整。 下面是附加的屏幕截图 下面是我的xml布局代码 <android.support.v4.widget.DrawerLayout xmlns:android="http:

我正在使用
工具栏
作为我的
支持操作栏
操作栏活动
中,该活动由一个
查看页面
组成,其中有4个选项卡可供滚动,其中我面临一个奇怪的问题。此活动在用户登录后启动。当我第一次登录我的应用程序时,就没有任何问题了。但是,当我第二次启动应用程序时,工具栏最上面的部分被隐藏,然后它开始从顶部滑动,并在系统栏下面的活动布局中进行调整。 下面是附加的屏幕截图

下面是我的xml布局代码

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:layout_above="@+id/bottomTabBar">

        </FrameLayout>

        <include
            android:id="@+id/bottomTabBar"
            layout="@layout/bottom_tab_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"/>

    </RelativeLayout>

    <include
        android:id="@+id/drawerContent"
        layout="@layout/drawer_content"
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"/>

</android.support.v4.widget.DrawerLayout>


是否有人知道这个问题,或者有人暗示我做错了什么?任何帮助都将不胜感激。提前感谢。

在父布局中使用属性
android:fitsystemwindows=“true”
,或者在主题中设置该属性以在
样式中全局生效。xml
apptheme


true

在父布局中使用属性
android:fitsystemwindows=“true”
,或者在主题中设置该属性以在
style.xml中全局生效


true

将父布局的此属性设置为false

android:fitsSystemWindows="false"
True:如果为True,则布局与状态栏合并

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerLayout"
android:fitsSystemWindows="false"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:layout_above="@+id/bottomTabBar">

    </FrameLayout>

    <include
        android:id="@+id/bottomTabBar"
        layout="@layout/bottom_tab_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

<include
    android:id="@+id/drawerContent"
    layout="@layout/drawer_content"
    android:layout_width="300dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"/>
False:如果为False,则在状态栏下方绘制布局

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerLayout"
android:fitsSystemWindows="false"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:layout_above="@+id/bottomTabBar">

    </FrameLayout>

    <include
        android:id="@+id/bottomTabBar"
        layout="@layout/bottom_tab_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

<include
    android:id="@+id/drawerContent"
    layout="@layout/drawer_content"
    android:layout_width="300dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"/>


将父布局的此属性设置为false

android:fitsSystemWindows="false"
True:如果为True,则布局与状态栏合并

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerLayout"
android:fitsSystemWindows="false"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:layout_above="@+id/bottomTabBar">

    </FrameLayout>

    <include
        android:id="@+id/bottomTabBar"
        layout="@layout/bottom_tab_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

<include
    android:id="@+id/drawerContent"
    layout="@layout/drawer_content"
    android:layout_width="300dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"/>
False:如果为False,则在状态栏下方绘制布局

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerLayout"
android:fitsSystemWindows="false"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:layout_above="@+id/bottomTabBar">

    </FrameLayout>

    <include
        android:id="@+id/bottomTabBar"
        layout="@layout/bottom_tab_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

<include
    android:id="@+id/drawerContent"
    layout="@layout/drawer_content"
    android:layout_width="300dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"/>


我已经尝试过了,但它不会影响问题。@AshishKumarGupta然后将此属性添加到父视图中,然后再试一次
android:paddingTop=“?android:attr/actionBarSize”
填充是如何实现的?它将在我的工具栏上方创建一个空白。我已经尝试过了,但它不会影响问题。@AshishKumarGupta然后将此属性添加到父视图并重试
android:paddingTop=“?android:attr/actionBarSize”
填充是如何实现的?它将在我的工具栏上方创建一个空白。不做任何更改吗?不,试试这个它会工作的。如果可能,请向我们展示xml代码。我已经编辑了问题,请检查我的活动的xml代码。好的,将ActionBarActivity更改为AppCompativeActivity不会进行任何更改吗?不,试试这个它会起作用的。如果可能,请向我们展示xml代码。我已经编辑了问题,请检查我的活动的xml代码。好的,将ActionBarActivity更改为AppCompatActivity