Note that there are some explanatory texts on larger screens.

plurals
  1. POSoft keyboard covers an EditText in a PopupWindow
    primarykey
    data
    text
    <p>I've thrown together a simple test project that displays a PopupWindow containing an EditText (on Android 2.2). When I tap the EditText, the soft keyboard is shown, as I would expect. However, the soft keyboard covers the EditText, and I cannot get the screen to pan to keep the EditText in view in the way I would have thought it should. My code:</p> <p>TestAdjustPanActivity.java:</p> <pre><code>package com.example; import android.app.Activity; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.view.Gravity; import android.widget.PopupWindow; public class TestAdjustPanActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final PopupWindow pw = new PopupWindow(this); pw.setContentView(getLayoutInflater().inflate(R.layout.popup, null, false)); pw.setWidth(400); pw.setHeight(600); pw.setFocusable(true); pw.setOutsideTouchable(true); pw.setTouchable(true); pw.setBackgroundDrawable(new BitmapDrawable()); // This is the line referred to in the edit: pw.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); findViewById(R.id.main).post(new Runnable() { public void run() { pw.showAtLocation(findViewById(R.id.main), Gravity.NO_GRAVITY, 0, 0); } }); } } </code></pre> <p>main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>popup.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#666666" android:orientation="vertical" &gt; &lt;EditText android:id="@+id/current_password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="40dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="300dp" /&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; </code></pre> <p>...and my AndroidManifest.xml does contain the line <code>android:windowSoftInputMode="stateUnspecified|adjustPan"</code> in the tag for the one and only activity in the app.</p> <p>Any ideas? None of the other posts on SO related to this issue have done it for me. What am I missing that's keeping the view from panning the way I would expect it to?</p> <p>EDIT: I tried adding a line in TestAdjustPanActivity as indicated, which caused the screen to pan perfectly on an Android 3.2 device I have. However, it still doesn't pan on my Android 2.2 device, which makes this even more confusing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload