安卓键盘向下滑动,留下白色空间[英] Android keyboard slides down leaving white space behind

本文是小编为大家收集整理的关于安卓键盘向下滑动,留下白色空间的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

I am using action bar search widget. After a search when the keyboard goes down it leaves a white space for a moment. The screen background is dark which makes it look awful. I tried adding android:hardwareAccelerated="true" in the manifest file without any success. Any suggestion will be greatly appreciated. Below is the link of the screenshot-

http://www.flickr.com/photos/54884891@N05/10310528196/

推荐答案

In case I understood your issue right (during the animation where the software keyboard scroll down, the space on the screen that the keyboard took is white, and the activity is not re sized until the keyboard animation is over), the solution to your problem hides in the main layout !

You said that the screen background of your application is dark. Well in case the screen background is the same in all your activities, what you can do is to set a common screen background color / picture for the application theme. And hence during the keyboard animation, or during the load between activities, you will see the color / picture that you have set (it will be the default background color / picture until the activity layout is loaded and applied).

To achieve this, add the following in the styles.xml file :

<!-- Application theme -->
<style name="AppTheme" >
    <item name="android:windowBackground"> ... </item>
    <!-- Put the color , picture that you need -->
</style>

You can also specify the main theme that your application is using (if any) by specifying the style parent like this :

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" >

And then go to your AndroidManifest.xml file and add the following to the application tag :

<application
    [...]
    android:theme="@style/AppTheme"
    [...] >

Try it and you should see the color that you have specified in the theme instead of the plain white background (which is mainly defined by the main android theme that you are using, and which we are modifying using the custom theme).

其他推荐答案

Try this code,

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"