[英]Android White Background when keyboard fades away
来自不同用户但相同的问题视频
我有一个背景图像设置如下:
.pane {
background-image: url("../img/inner-banner-bg.jpg");
background-repeat: repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}
在我的 config.xml 中
<preference name="Fullscreen" value="false"/>
现在我遇到的问题是当我点击完成/搜索后键盘消失时,在键盘覆盖的空间过渡期间它会留下白色背景,例如 0.5,看起来有点糟糕。
当键盘关闭时,它不会收缩,但会留下白色间隙。 如何让键盘不缩小背景后面的视图?
当我设置
<preference name="Fullscreen" value="true"/>
它不会发生。 我也在使用 Ionic 插件键盘。
无论如何,我可以使键盘淡入淡出的过渡不显示白色背景吗?
编辑:这是我的安卓设置
<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>
还有我的配置设置
<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"/>
在 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"
]
在我的网络视图中,我使用 ion-view 和 ion-content
<ion-view>
<ion-content class="has-header has-tabs">
在 AndroidManifest.xml 文件中尝试将windowSoftInputMode
属性设置为adjustNothing :
android:windowSoftInputMode="adjustNothing"
它适用于我的 Ionic 项目,避免在软键盘打开时调整 Cordova webview 的大小。
那是你的windowBackground
偷看。 您可能正在使用蓝绿色背景绘制主题的白色背景。 修改您的主题以包含更好的背景颜色并尽可能从布局中删除背景以提高绘图性能。
<style name="MyAppTheme" parent="Theme.DeviceDefault.NoActionBar">
...
<item name="android:windowBackground">#ff000000</item>
...
</style>
放:
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowBackground">@drawable/gradient</item>
</style>
在styles.xml源代码中
嘿,有一个简单的解决方法
您需要将 overflow-scroll="false" 添加到您的离子内容中,这应该可以解决它
<ion-content class="padding has-header has-footer" overflow-scroll="false">
相关主题离子论坛
它的发生是因为窗口重新调整大小以为软输入区域腾出空间
在 AndroidManifest.xml 中使用android:windowSoftInputMode="adjustNothing"
<activity android:windowSoftInputMode="adjustNothing"
..
...
</activity>
打开你的平台 -> app ->src ->AndroidManifest.xml
编辑
android:windowSoftInputMode="adjustResize"
到
android:windowSoftInputMode="adjustNothing"
这样做为我解决了这个问题:
我试图使用选择器“app-login”将背景应用到我的应用程序的登录页面。
我在页面内添加了一个 div 并将其背景设置为我想要的图像。 但是每当我打开键盘时,我都会看到键盘上方的部分屏幕变成白色,关闭键盘后留下空白。
添加 height: 100% 或 height: 100vh 没有解决问题。 它在某些设备上解决了,但在其他设备上没有解决。
这样做:不要向 ion-content 或 div 添加背景,只需进入您的全局 CSS 文件并添加:
app-login{ background-image: url("./assets/bg@2x.png"); background-repeat: no-repeat; background-size: cover; }
将 CSS 选择器更改为您页面的选择器,并相应地将 url 更改为您自己的图像。
在“App.js”中添加以下代码。 添加
$window.addEventListener('native.keyboardhide', function (event) {
$rootScope.$broadcast('native.keyboardhide', event);
});
当 app.run() 方法使用 $window 和 $rootScope 依赖调用时。 另外,添加
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
在 $ionicPlatform.ready() 中。
请通过检查您的应用程序来确保您的代码已更新。 如果未更新,请尝试删除并添加平台并重建您的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.