PopupWindow не отображается над DialogFragment - PullRequest
0 голосов
/ 10 марта 2019

Существует DialogFragment со следующей структурой макета:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>

    <variable
        name="vm"
        type="io.evalon.scene.intro.check.permission.PermissionPopupVm" />
</data>

<androidx.cardview.widget.CardView
    android:layout_width="500dp"
    android:layout_height="500dp"
    android:background="#00000000"
    app:cardBackgroundColor="#fff"
    app:cardCornerRadius="10dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <ImageView
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:src="@drawable/permission_title"
                android:tint="@color/success_green"
                android:visibility="invisible" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:text="Title"
                android:textAppearance="@style/TitleText"
                android:textColor="#000"
                android:textSize="30dp" />
        </LinearLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Text"
            android:textColor="#000" />

        <androidx.recyclerview.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adapter="@{vm.adapter}"
            android:orientation="vertical"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
    </LinearLayout>
</androidx.cardview.widget.CardView>
</layout>

enter image description here

PopupWindow появляется при нажатии кнопки информации этого DialogFragment.

    fun showPermissionDetailInfo(anchorView: View) {
    //anchorView = infoButton
    val popup = PopupWindow(anchorView.context)
    val view = LayoutInflater.from(anchorView.context)
        .inflate(R.layout.popup_permission_info, null, false)
    popup.contentView = view
    popup.isFocusable = true
    popup.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
    view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
    val xOffset = -(view.measuredWidth - anchorView.width)
    popup.showAsDropDown(anchorView, xOffset + 20, -50)

    }

Когда я нажимаю кнопку «Информация» в Индексе 1, PopUpWindow отображается нормально.

enter image description here

Но когда я нажимаю кнопку «Информация» в Index 2, всплывающее окно никогда не отображается.

Я ожидаю, что это произойдет, потому что PopupWindow создается там, где оно находится за пределами родительского окна, но я думаю, что есть обходной путь.

Как мне решить мою проблему?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...