Android 工具栏在棒棒糖中不可见?

Android 工具栏在棒棒糖中不可见?,android,toolbar,Android,Toolbar,在android 4.4和以前的版本中,工具栏是可见的。当我在棒棒糖版本中安装我的应用程序时,工具栏被框架布局隐藏。如何解决这个问题 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">

在android 4.4和以前的版本中,工具栏是可见的。当我在棒棒糖版本中安装我的应用程序时,工具栏被框架布局隐藏。如何解决这个问题

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
  <android.support.v4.widget.DrawerLayout       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:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:openDrawer="hide">
      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
     android:orientation="vertical">
          <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="@color/white"
         app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
         app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    >
</android.support.v7.widget.Toolbar>

<FrameLayout

    android:id="@+id/content_frame"
    android:layout_below="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

将根布局更改为相对布局,并将框架布局放在第一位,其他所有内容都放在框架布局之后

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

  <FrameLayout

    android:id="@+id/content_frame"
    android:layout_below="@+id/aaa"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

  <android.support.v4.widget.DrawerLayout       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:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:openDrawer="hide">
      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
     android:orientation="vertical">
          <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="@color/white"
         app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
         app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    >
</android.support.v7.widget.Toolbar>

将根布局更改为RelativeLayout,并将框架布局放在第一位,其他所有内容都放在框架布局之后

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

  <FrameLayout

    android:id="@+id/content_frame"
    android:layout_below="@+id/aaa"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

  <android.support.v4.widget.DrawerLayout       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:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:openDrawer="hide">
      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
     android:orientation="vertical">
          <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="@color/white"
         app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
         app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    >
</android.support.v7.widget.Toolbar>

尝试下面的代码-

<android.support.v4.widget.DrawerLayout
    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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="hide">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary"
            app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <FrameLayout

            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

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

在res/values-v21/style.xml下创建一个样式表

<resources> 

<style name="AppTheme.NoActionBar"> 
<item name="windowActionBar">false</item> 
<item name="windowNoTitle">true</item> 
<item name="android:windowDrawsSystemBarBackgrounds">true</item> 
<item name="android:statusBarColor">@android:color/transparent</item> 
</style> 

</resources>

假的
真的
真的
@android:彩色/透明
尝试下面的代码-

<android.support.v4.widget.DrawerLayout
    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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="hide">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary"
            app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <FrameLayout

            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

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

在res/values-v21/style.xml下创建一个样式表

<resources> 

<style name="AppTheme.NoActionBar"> 
<item name="windowActionBar">false</item> 
<item name="windowNoTitle">true</item> 
<item name="android:windowDrawsSystemBarBackgrounds">true</item> 
<item name="android:statusBarColor">@android:color/transparent</item> 
</style> 

</resources>

假的
真的
真的
@android:彩色/透明

让它看起来像这样我希望它能工作

 <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>

</android.support.design.widget.AppBarLayout>

让它看起来像这样我希望它能工作

 <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>

</android.support.design.widget.AppBarLayout>



为框架布局添加页边空白,然后尝试添加
android:layout\u height=“wrap\u content”android:minHeight=“?attr/actionBarSize”
工具栏我尝试了这种逻辑。我在kitkat中工作得很好,但在棒棒糖中不工作。这里是
android:layout_below=“@+id/aaa”
@IntelliJAmiya aaa是一个工具栏id。给框架布局加上页边空白,然后尝试添加
android:layou height=“wrap_content”android:minHeight=“?attr/actionBarSize”
工具栏我尝试了这个逻辑。我在kitkat中工作得很好,但在棒棒糖中不工作这里是
android:layout_below=“@+id/aaa”
@IntelliJAmiya aaa是一个工具栏id.@Gopal:你可以发布不同版本的图片吗?我发布了两个不同版本的照片?尝试从xml文件中删除最外层的线性布局。是的。。。继续chat@Gopal:你可以发布不同版本的图片吗?我发布了两张不同版本的照片?请尝试从xml文件中删除最外层的线性布局。让我们看看。是的。。。继续聊天