简体   繁体   English

键盘消失时的 Android 白色背景

[英]Android White Background when keyboard fades away

Video of the problem from a different user but its the same来自不同用户但相同的问题视频

http://imgur.com/ca2cNZv http://imgur.com/ca2cNZv

I have a background image set as follows :我有一个背景图像设置如下:

  .pane {
  background-image:  url("../img/inner-banner-bg.jpg");
  background-repeat: repeat;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  background-size: cover;
}

And in my config.xml在我的 config.xml 中

<preference name="Fullscreen" value="false"/>

Now the problem I am having is when the keyboard fades away after I hit done / search, it leaves a white background for like 0.5 during the transition for the space the keyboard covered and it looks a bit bad.现在我遇到的问题是当我点击完成/搜索后键盘消失时,在键盘覆盖的空间过渡期间它会留下白色背景,例如 0.5,看起来有点糟糕。

When the keyboard closes it unshrinks but leaves white gap.当键盘关闭时,它不会收缩,但会留下白色间隙。 How can I get the keyboard to not shrink the view behind the backdrop ?如何让键盘不缩小背景后面的视图?

When I set当我设置

<preference name="Fullscreen" value="true"/>

It doesn't happen.它不会发生。 I am also using the Ionic Plugin Keyboard.我也在使用 Ionic 插件键盘。

Anyway I can make the transition of the keyboard fading not display the white background ?无论如何,我可以使键盘淡入淡出的过渡不显示白色背景吗?

Edit : Here's my android settings编辑:这是我的安卓设置

<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

And my config Settings还有我的配置设置

  <access launch-external="yes" origin="geo:*"/>
  <allow-intent href="geo:*"/>
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="android-minSdkVersion" value="16"/>
  <preference name="BackupWebStorage" value="none"/>
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="4000"/>
  <preference name="FadeSplashScreen" value="false"/>
  <preference name="ShowSplashScreenSpinner" value="true"/>
  <preference name="KeyboardShrinksView" value="false"/>

And in the Package.json在 Package.json 中

  "dependencies": {
    "gulp": "^3.5.6",
    "gulp-sass": "^2.0.4",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0"
  },
  "devDependencies": {
    "bower": "^1.3.3",
    "gulp-util": "^2.2.14",
    "shelljs": "^0.3.0"
  },
  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "cordova-plugin-geolocation",
    "cordova-plugin-network-information",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [
    "android",
    "ios"
  ]

In my web view I use ion-view and ion-content在我的网络视图中,我使用 ion-view 和 ion-content

<ion-view>
    <ion-content class="has-header has-tabs">

In AndroidManifest.xml file try to set windowSoftInputMode attribute to adjustNothing :在 AndroidManifest.xml 文件中尝试将windowSoftInputMode属性设置为adjustNothing

android:windowSoftInputMode="adjustNothing"

It worked for my Ionic project, avoiding the resize of Cordova webview when soft keyboard is on.它适用于我的 Ionic 项目,避免在软键盘打开时调整 Cordova webview 的大小。

That is your windowBackground peeking through.那是你的windowBackground偷看。 You are probably drawing over the white background of your Theme with that teal background.您可能正在使用蓝绿色背景绘制主题的白色背景。 Modify your theme to include a better background color and remove the background from your layout if possible to improve drawing performance.修改您的主题以包含更好的背景颜色并尽可能从布局中删除背景以提高绘图性能。

<style name="MyAppTheme" parent="Theme.DeviceDefault.NoActionBar">
  ...
  <item name="android:windowBackground">#ff000000</item>
  ...
</style>

Put:放:

<style name="AppTheme" parent="AppBaseTheme">
     <item name="android:windowBackground">@drawable/gradient</item>
</style>

In styles.xml source在styles.xml源代码中

Hey there is a simple workaround for this嘿,有一个简单的解决方法

you need to add overflow-scroll="false" to your ion-content this should fix it您需要将 overflow-scroll="false" 添加到您的离子内容中,这应该可以解决它

<ion-content class="padding has-header has-footer" overflow-scroll="false">

related topic Ionicforum相关主题离子论坛

Its happen because window re size itself to make room for the soft input area它的发生是因为窗口重新调整大小以为软输入区域腾出空间

use android:windowSoftInputMode="adjustNothing" in AndroidManifest.xml在 AndroidManifest.xml 中使用android:windowSoftInputMode="adjustNothing"

<activity android:windowSoftInputMode="adjustNothing"
..
...
</activity>

Open your platform -> app ->src ->AndroidManifest.xml打开你的平台 -> app ->src ->AndroidManifest.xml

Edit编辑

android:windowSoftInputMode="adjustResize"

To

android:windowSoftInputMode="adjustNothing"

Doing this solved it for me:这样做为我解决了这个问题:

I was trying to apply background to the login page of my app with selector 'app-login'.我试图使用选择器“app-login”将背景应用到我的应用程序的登录页面。

I added a div inside the page and set its background to the image I wanted.我在页面内添加了一个 div 并将其背景设置为我想要的图像。 But whenever I opened the keyboard, I had some part of the screen turned white just above the keyboard and white space left after the keyboard was closed.但是每当我打开键盘时,我都会看到键盘上方的部分屏幕变成白色,关闭键盘后留下空白。

Adding height: 100% or height: 100vh did not solve the issue.添加 height: 100% 或 height: 100vh 没有解决问题。 It solved on some devices but not in others.它在某些设备上解决了,但在其他设备上没有解决。

DO THIS: Instead of adding background to ion-content or div just go into your global CSS file and add:这样做:不要向 ion-content 或 div 添加背景,只需进入您的全局 CSS 文件并添加:

 app-login{ background-image: url("./assets/bg@2x.png"); background-repeat: no-repeat; background-size: cover; }

Change the CSS selector to the selector of your page and change the url to your own image accordingly.将 CSS 选择器更改为您页面的选择器,并相应地将 url 更改为您自己的图像。

Add the following code in your 'App.js'.在“App.js”中添加以下代码。 add添加

$window.addEventListener('native.keyboardhide', function (event) {
    $rootScope.$broadcast('native.keyboardhide', event);
});

when app.run() method call with $window and $rootScope dependency.当 app.run() 方法使用 $window 和 $rootScope 依赖调用时。 also, add另外,添加

    if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        cordova.plugins.Keyboard.disableScroll(true);
    }

in $ionicPlatform.ready().在 $ionicPlatform.ready() 中。

please ensure that your code is updated by inspecting your app.请通过检查您的应用程序来确保您的代码已更新。 If it's not updated then try to remove and add platform and rebuild your app.如果未更新,请尝试删除并添加平台并重建您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM