我的工具栏在 API 级别 19 (Kitkat) 上不显示,而在 API 级别 21 上显示

2024-01-18

我的代码没有在 Kitkat 上显示工具栏。
这是我针对两个 Android 版本的屏幕截图。

奇巧版本:

棒棒糖版本:

这背后的原因可能是什么。

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.global.market">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/image_front"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".detailactivity"
            android:label="@string/app_name" />
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

        <meta-data android:name="com.google.android.gms.version" android:value="6111000" />
    </application>

</manifest>

样式.xml 文件

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBarOverlay">false</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

Activity_main.xml

  <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:ads="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="start">


    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />


    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        android:clickable="true">

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

    <ExpandableListView
        android:id="@+id/exp_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="160dp"
        android:indicatorRight="?android:attr/expandableListPreferredItemIndicatorRight"
        android:background="@android:color/white"
        android:footerDividersEnabled="true"
        android:groupIndicator="@null">
    </ExpandableListView>

            <!--<ListView-->
                <!--android:background="@android:color/white"-->
                <!--android:id="@+id/menuList"-->
                <!--android:layout_width="match_parent"-->
                <!--android:layout_height="match_parent"-->
                <!--android:layout_marginTop="10dp" />-->
        </LinearLayout>
    </android.support.design.widget.NavigationView>

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

MainActivity.java

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

                setContentView(R.layout.activity_main);
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
                if (toolbar != null) {
                    toolbar = (Toolbar) findViewById(R.id.toolbar);
                    setSupportActionBar(toolbar);
                   getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                }
}

构建.gradle 文件

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    ext {
        supportLibVersion = '23.4.0'  // variable that can be referenced to keep support libs consistent
    }

    defaultConfig {
        applicationId "com.global.market"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.android.support:cardview-v7:23.0.+'
    compile 'com.android.support:recyclerview-v7:23.0.+'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.github.gabrielemariotti.cards:cardslib-core:2.1.0'
    compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.1.0'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
    compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
    compile 'com.google.android.gms:play-services:6.1.11'



}

默认情况下,AppBar 具有在棒棒糖之后起作用的高度。因此,尽管布局层次结构不同,它始终可见。但在较低版本(棒棒糖下方)上,工具栏可能会绘制在其他布局下方。

因此,请重新排序布局项目以使工具栏可见。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我的工具栏在 API 级别 19 (Kitkat) 上不显示,而在 API 级别 21 上显示 的相关文章

  • Git 到 TFS 源代码管理迁移

    我想看看 TFS 如何为我的命令工作 所以我想将我们当前的 GIT 存储库移动到 TFS 数据库 我们使用 GIT 来获得普遍的分支支持 因此我想使用 TFS 2010 来解决该问题 现在的问题是 如何将 GIT 存储库导出到 TFS 显然
  • 如何让 mod_wsgi 在 Mac 上运行?

    几个小时以来 我一直在尝试在 Mac 上安装最新版本的 mod wsgi 3 3 我使用的是 Snow Leopard 并且有系统附带的 Apache Apache 2 2 15 和 Python 2 6 1 r261 67515 版本 我
  • PyCharm和源代码控制,.idea目录,提交还是不提交,这就是问题

    我开始了新的PyCharm http www jetbrains com pycharm 项目并希望对其进行版本控制水银 http mercurial selenic com 项目目录中有一个 idea 目录 其中包含以下文件 以及我对是否
  • 相当于 svnblame/gitblame 的clearcase?

    在 Rational Software 的 Clearcase 中 有一个cleartool子命令或其他命令行工具 相当于blameSVN 中的命令还是 git 中的命令 最接近的一个是cleartool annotate https ww
  • 运行 flutter doctor 吐出错误:标准错误:致命:坏对象 HEAD

    我已经从官方网站安装了 Flutter 和 Android Studio 我是 Git GitHub 移动开发和 Android 开发的新手 我试图在命令提示符 Windows 10 中运行 flutter doctor 命令 但是 它会以
  • 如何从 git 存储库中删除作者?

    如果我创建一个 Git 存储库并公开发布它 例如在 GitHub 等上 并且我收到存储库贡献者的请求 无论出于何种原因删除或隐藏他们的名字 有没有一种方法可以轻松做到这一点 基本上 我有这样的请求 可能想将他们的姓名和电子邮件地址替换为 匿
  • 本地分支显示在 GitHub 的“网络”视图上

    我们使用 Git 我们的工作流程由 dev 和 master 分支组成 它们位于 GitHub 和每个开发人员的本地存储库上 不会直接在 master 或 dev 上执行任何工作 而是在本地分支中执行工作 并且仅在 dev 上进行合并 然后
  • 相当于 svn 对 Perforce 的责备

    命令行上是否有相当于 svn 对 Perforce 的责备 p4 annotate不显示用户名 仅显示变更集编号 没有祖先历史 我目前必须通过祖先跟踪代码并与文件日志进行比较 并且必须有一种更简单的方法 也许是 F OSS 实用程序 我对b
  • 如何在运行“更新”之前查看存储库中的文件

    I run hg pull这向我的存储库添加了新的更改 在使用新更改更新我的工作目录之前 我想查看这些新文件 更改 我相信我使用的 SVNsvn st u但在 Mercurial 中是如何完成的呢 在拉动之前 您可以使用 hg incomi
  • 撤消 git pull,如何将存储库恢复到旧状态

    有什么方法可以恢复或撤消 git pull 以便我的源 存储库将恢复到执行 git pull 之前的旧状态 我想这样做是因为它合并了一些我不想这样做的文件 但只合并了其他剩余的文件 那么 我想找回这些文件 可以吗 编辑 我想撤消 git m
  • 如何在版本控制系统中安全地保存密钥和密码?

    我在版本控制系统中保留了开发和生产服务器的主机名和端口等重要设置 但我知道这是不好的做法保留secrets 如私钥和数据库密码 位于 VCS 存储库中 但密码 就像任何其他设置一样 似乎应该进行版本控制 所以呢is保持密码版本控制的正确方法
  • 两个目录中相同文件的 Git Diff 总是会导致“重命名”

    git diff no index no prefix summary U4000 目录1 目录2 这按预期工作 因为它返回两个目录之间所有文件的差异 添加的文件按预期输出 删除的文件也会产生预期的 diff 输出 但是 由于 diff 将
  • Mac OSX 上有哪些与 TortoiseSVN 等效的软件? [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • Delphi TImageList 位图更改

    我正在使用 Delphi XE2 Update 3 Update 4 与我们的一些第 3 方组件不兼容 因此我们尚未更新 我在我的应用程序中使用 TImageList 我注意到很多时候当它从源视图切换到表单视图 F12 时 突然之前未修改的
  • 如何将 git 存储库中的现有目录设为 git 子模块

    我对 git submodules 很困惑 基本上我的问题是我无法让 git 理解这一点 main project submodule是一个子模块 我对 git 子模块有很好的经验 in my 点文件存储库 https github com
  • 您对版本控制进行到什么程度了? [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • hg 或 git 中的两个完整目录/项目之间存在差异?

    我继承了一个最初存储在 CVS 中的项目以及所有修订 我做了相当多的编辑 并且我试图比较我在原始目录中所做的所有更改 关于添加的新文件与旧文件 hg git 是否有某种实用程序可以让我进行树差异或类似性质的操作 也就是说 新添加的文件 删除
  • 如何在顶部工具栏的购物车图标上添加商品编号?安卓

    I saw some apps made it So I am intersting at how to do it I believe there must be some trick way to do it Example 我在菜单文
  • 如何从 SVN 获取所有未版本化文件的列表?

    有时 您正在开发并决定提交 却忘记了您在项目中创建了一些文件 然后几天后 你的朋友从 Subversion 中得到了你的版本 并抱怨有些文件似乎丢失了 你意识到了 啊糟糕 我忘记添加那些文件了 如何从 Subversion 获取不受版本控制
  • 有没有可以在 HTML 文档之间进行比较的 ruby​​ gem?

    事实证明 对两个不同的 html 文档进行比较是一个完全不同的问题 而不仅仅是对纯文本进行比较 例如 如果我在以下之间进行简单的 LCS 差异 Google and Google diff 结果不是 but a gt github com

随机推荐