Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to adjust a popup when the soft keyboard shows up

without soft keyboard

when soft keyboard shows up

I want to replicate this effect in my layout. But in my layout when the keyboard show up, my pop-up is not adjusted. The device adjust me the main activity below and not the popup.

this is my popup layout.xml :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sfondo_semi_trasparente_scuro">




<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:background="@color/white"
    android:orientation="vertical">





    <EditText
        android:id="@+id/textNomeGiocatoreNewTeam"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:hint="Nome giocatore"/>


    <EditText
        android:id="@+id/textNumeroMagliaGiocatoreNewTeam"
        android:inputType="number"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Numero Maglia"/>

    <Button
        android:id="@+id/buttonConfirmAddNewPlayer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Aggiungi giocatore"
        android:layout_gravity="center"/>


</LinearLayout>

Can someone help me?

like image 499
Luke Avatar asked May 13 '15 09:05

Luke


People also ask

How do I get rid of soft keyboard on Android?

You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.

How do I prevent keyboard from pushing overlay view up?

How do I prevent keyboard from pushing overlay view up? Add android:windowSoftInputMode="stateHidden|adjustPan" in required activity of your manifest file . This makes keyboard appear overlaying content, without making layout to recalculate it's height.


2 Answers

Try instead this:
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

like image 75
mongiabrothers Avatar answered Sep 22 '22 15:09

mongiabrothers


You can also add this to your AndroidManifest.xml

    <activity
        ...
        android:windowSoftInputMode="adjustResize"
    </activity>
like image 29
zek_w Avatar answered Sep 19 '22 15:09

zek_w