关闭键盘时,渐变背景得到白色(仅当列表视图有项) [英] Gradient background gets white when closing keyboard (only when list view has items)

查看:158
本文介绍了关闭键盘时,渐变背景得到白色(仅当列表视图有项)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的覆盖布局的整个背景的渐变。然而,当我关闭软键盘,约需要1秒的梯度调整为全高。这将产生您在下面的图片中看到的白色背景。

I have a gradient that covers the whole background of my layout. However when I close the software keyboard it takes about 1 second for the gradient to resize to full height. This produces the white background you see in the picture below.

我觉得做这样的事情

android:windowSoftInputMode="adjustPan"

不过,这将是不好的做法,因为列表视图中的很大一部分将下键盘被隐藏。梯度:

however this would be bad practice because a big part of the list view would be hidden under the keyboard. The gradient:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:useLevel="false" >
    <gradient
        android:startColor="#0d2d70"
        android:endColor="#007dbc"
        android:useLevel="false"
        android:type="linear"
        android:angle="45" />
</shape>

布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/gradient"
    android:padding="20dp" >

    <!-- input field is here -->

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/input_licence"
        android:divider="#FFFFFF"
        android:dividerHeight="1dp"
        android:padding="5dp"
        android:scrollbarStyle="outsideOverlay" >
    </ListView>


</RelativeLayout>

任何想法如何prevent白色的空间?

Any ideas how to prevent the white space?

推荐答案

我已经解决了我的问题。相反,设置背景绘制的每个活动,我将其设置在这样styles.xml

I've solved my problem. Instead of setting the background drawable for every activity, I set it in styles.xml like this

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

白色空间消失。

这篇关于关闭键盘时,渐变背景得到白色(仅当列表视图有项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆