fitsSystemWindows下推操作栏-Nativescript和Android 9.0

问题描述 投票:0回答:1

使用Nativescript:设置<item name="android:fitsSystemWindows">true</item>会增加Android 9.0上动作栏的高度。没有设置将停止SOFT_INPUT_ADJUST_RESIZE的工作。

Example picture of the extra height added by Nativescript

  • 尝试设置ADJUST_PAN
  • 尝试在main.ts中设置ADJUST_RESIZE
{
  "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 android-actionbar nativescript android-softkeyboard android-9.0-pie
1个回答
0
投票

这仍然是我的Android开发团队面临的主要问题。我们已经尽力解决此问题,但仍然没有任何乐趣。这个简单的问题使我们感到沮丧。

NativeScript小组-请,请您再看看这个问题。

基本在styles.xml中设置android:fitsSystemWindows以及在Android清单中设置android:windowSoftInputMode =“ adjustResize”,导致显示键盘时状态栏/操作栏改变高度。

您需要执行此操作,否则键盘将覆盖下面的内容,并且无法获取表单字段等。

我相当确定这与RadSideDraw没有关系。我们删除了侧边图,问题仍然存在。

我们发现了一种解决方法,可以在运行时停止此问题...https://github.com/NativeScript/nativescript-ui-feedback/issues/730#issuecomment-546592655

但是,在开发过程中,每次保存工作并重新加载仿真器/电话时,操作栏就会被推到状态栏下方。显示键盘后,操作栏便会正确地重新定位。

© www.soinside.com 2019 - 2024. All rights reserved.