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.

I thought of doing something like

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>

The layout:

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

Any ideas how to prevent the white space?

enter image description here

DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601

2 Answers2

1

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>

The white space disappears.

DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
0

it seems that the view is not getting invalidated after keyboard exits. Though i am not sure about the actual issue. I would suggest you to invalidate the view manually via code. Like,

container.invalidate();

http://developer.android.com/reference/android/view/View.html#invalidate()

Sivakumar S
  • 681
  • 5
  • 19