Android - 如何在软键盘出现时调整弹出窗口

Luk*_*uke 3 android popup adjustment soft-keyboard

没有软键盘

当软键盘出现时

我想在我的布局中复制这个效果.但是在我的布局中,当键盘出现时,我的弹出窗口没有调整.设备调整下面的主要活动,而不是弹出窗口.

这是我的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>
Run Code Online (Sandbox Code Playgroud)

有人能帮我吗?

小智 7

试试这个:
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);