Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 关闭键盘时渐变背景变为白色(仅当列表视图中有项目时)_Android_Android Layout_Android Listview - Fatal编程技术网

Android 关闭键盘时渐变背景变为白色(仅当列表视图中有项目时)

Android 关闭键盘时渐变背景变为白色(仅当列表视图中有项目时),android,android-layout,android-listview,Android,Android Layout,Android Listview,我有一个渐变,覆盖了我布局的整个背景。但是,当我关闭软件键盘时,渐变需要大约1秒的时间才能调整到全高。这将生成您在下图中看到的白色背景 我想做一些类似的事情 android:windowSoftInputMode="adjustPan" 然而,这将是一种糟糕的做法,因为列表视图的很大一部分将隐藏在键盘下。坡度: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android

我有一个渐变,覆盖了我布局的整个背景。但是,当我关闭软件键盘时,渐变需要大约1秒的时间才能调整到全高。这将生成您在下图中看到的白色背景

我想做一些类似的事情

android:windowSoftInputMode="adjustPan"
然而,这将是一种糟糕的做法,因为列表视图的很大一部分将隐藏在键盘下。坡度:

<?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>

有没有办法防止出现空白


键盘退出后,视图似乎没有失效。虽然我不确定实际的问题。我建议您通过代码手动使视图无效。像

container.invalidate();

键盘退出后,视图似乎没有失效。虽然我不确定实际的问题。我建议您通过代码手动使视图无效。像

container.invalidate();

我已经解决了我的问题。我没有为每个活动设置可绘制的背景,而是像这样在styles.xml中设置它

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

@可拉伸/梯度

空白消失了。

我已经解决了我的问题。我没有为每个活动设置可绘制的背景,而是像这样在styles.xml中设置它

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

@可拉伸/梯度

空白消失。

我应该把这一行放在哪里?可能是失去焦点。我刚刚注意到,这只发生在列表视图中有项目时,但仍然没有解决方案。我编辑了我的问题,我应该把这一行放在哪里?可能是因为失去了焦点。我刚刚注意到,当列表视图中有项目时,这种情况就会发生,但仍然没有解决方案。我编辑了我的问题