fitsSystemWindows 将操作栏向下推 - Nativescript & Android 9.0

fitsSystemWindows pushes action bar down - Nativescript & Android 9.0

使用 Nativescript:设置 <item name="android:fitsSystemWindows">true</item> 在 android 9.0 上增加操作栏的高度。不设置会停止 SOFT_INPUT_ADJUST_RESIZE 工作。

Example picture of the extra height added by Nativescript

{
  "nativescript": {
    "id": "nl.desoftwareontwikkelaar.xxx",
    "tns-android": {
      "version": "6.0.0"
    },
    "tns-ios": {
      "version": "6.0.1"
    }
  },
  "description": "",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "scripts": {
    "lint": "tslint \"src/**/*.ts\""
  },
  "dependencies": {
    "@angular/animations": "8.0.3",
    "@angular/common": "8.0.3",
    "@angular/compiler": "8.0.3",
    "@angular/core": "8.0.3",
    "@angular/forms": "8.0.3",
    "@angular/http": "8.0.0-beta.10",
    "@angular/platform-browser": "8.0.3",
    "@angular/platform-browser-dynamic": "8.0.3",
    "@angular/router": "8.0.3",
    "@nota/nativescript-webview-ext": "6.0.0-alpha.2",
    "nativescript-advanced-webview": "3.0.2",
    "nativescript-angular": "8.0.2",
    "nativescript-appversion": "1.4.2",
    "nativescript-calendar": "2.1.0",
    "nativescript-directions": "1.3.0",
    "nativescript-email": "1.5.4",
    "nativescript-iqkeyboardmanager": "1.5.1",
    "nativescript-mapbox": "4.4.1",
    "nativescript-oauth2": "1.4.3",
    "nativescript-phone": "1.4.0",
    "nativescript-plugin-firebase": "9.0.2",
    "nativescript-theme-core": "1.0.6",
    "nativescript-ui-listview": "7.0.1",
    "nativescript-ui-sidedrawer": "7.0.0",
    "nativescript-web-image-cache": "5.0.0",
    "reflect-metadata": "0.1.13",
    "rxjs": "6.5.2",
    "tns-core-modules": "6.0.1",
    "uglifyjs-webpack-plugin": "2.1.3",
    "zone.js": "0.9.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "8.0.3",
    "@nativescript/schematics": "0.6.0",
    "@ngtools/webpack": "8.0.6",
    "codelyzer": "5.1.0",
    "nativescript-dev-webpack": "1.0.1",
    "tslint": "5.18.0",
    "tns-platform-declarations": "6.0.1",
    "node-sass": "4.12.0",
    "typescript": "3.4.5"
  },
  "gitHead": "803cec054c44c99eaa59cdc267993e6346f6cb3a",
  "readme": "NativeScript Application",
  "author": "De Software Ontwikkelaar"
}
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- theme to use FOR launch screen-->
    <style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>

        <item name="colorPrimary">@color/ns_primary</item>
        <item name="colorPrimaryDark">@color/ns_primaryDark</item>
        <item name="colorAccent">@color/ns_accent</item>

        <item name="android:windowBackground">@drawable/splash_screen</item>

        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:fitsSystemWindows">true</item>
    </style>

    <style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
    </style>

    <!-- theme to use AFTER launch screen is loaded-->
    <style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>

        <item name="colorPrimary">@color/ns_primary</item>
        <item name="colorPrimaryDark">@color/ns_primaryDark</item>
        <item name="colorAccent">@color/ns_accent</item>
    </style>

    <style name="AppTheme" parent="AppThemeBase">
    </style>

    <!-- theme for action-bar -->
    <style name="NativeScriptToolbarStyleBase" parent="Widget.AppCompat.Toolbar">
        <item name="android:background">@color/ns_primary</item>
        <item name="theme">@style/ThemeOverlay.AppCompat.ActionBar</item>
        <item name="popupTheme">@style/ThemeOverlay.AppCompat</item>
    </style>

    <style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
    </style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android" package="__PACKAGE__" android:versionCode="10005" android:versionName="1.0.5">
    <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <application android:name="com.tns.NativeScriptApplication" android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/AppTheme">
        <activity android:name="com.tns.NativeScriptActivity" android:label="@string/title_activity_kimera" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode" android:theme="@style/LaunchScreenTheme" android:screenOrientation="unspecified" android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
            <meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.tns.ErrorReportActivity" />
    </application>
</manifest>

没有设置的情况是预期的结果。 ADJUST_RESIZE 在这里不起作用,因为 fitsSystemWindows 的值未设置为 true。

Example expected result and current result without the setting

这仍然是我在 Android 的开发团队的主要问题。我们已经尝试了我们能想到的一切来解决这个问题,但仍然没有快乐。我们已经为这个简单的问题苦恼了好几天。

NativeScript 团队 - 请再看看这个问题。

基本上在 styles.xml 中设置 android:fitsSystemWindows 以及 Android 清单中的 android:windowSoftInputMode="adjustResize" 会导致状态栏/操作栏在以下情况下更改高度显示键盘。

您需要这样做,否则键盘会覆盖下面的内容,并且无法进入表单字段等。

我相当确定这与 RadSideDraw 无关。我们删除了侧边线,问题仍然存在。

我们找到了解决运行时问题的方法... https://github.com/NativeScript/nativescript-ui-feedback/issues/730#issuecomment-546592655

然而,在开发过程中,每次您保存您的工作和模拟器/phone 重新加载时,操作栏都会被推到状态栏下方。当显示键盘时,Actionbar 会正确地重新定位。