简体   繁体   中英

ListView isn't resizing when keyboard is shown

I have an Activity which shows a ListView. The items in the ListView have EditText fields in them, so when they tap a textfield the virtual keyboard slides into view. It is covering the ListView so you can't see the items behind the keyboard.

I've configured the Manifest for that Activity to adjustResize:

<activity android:name=".StatisticalActivity"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar"
                  android:screenOrientation="portrait"
                  android:windowSoftInputMode="adjustResize"
                  >

.. but it isn't resizing when the keyboard is shown.

This the layout for my activity:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rootView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    >

    <RelativeLayout
        android:id="@+id/toolbar"
        android:layout_width="fill_parent"
        android:layout_height="40sp" android:paddingLeft="4dp" android:background="@drawable/toolbar_gradient" android:paddingRight="6dp">

        ...

    </RelativeLayout>

    <ListView
        android:id="@+id/tableView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#333"
    />
</LinearLayout>

What am I doing wrong?

If you're setting the Activity to Full Screen using WindowManager.LayoutParams.FLAG_FULLSCREEN , then the auto-resizing of the view doesn't work. So unfortunately, your best bet is to not use Full Screen (ie have the status bar at the top visible), at which point the resizing will work normally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM