У меня есть PopupWindow, которое содержит ViewPager, в каждом фрагменте которого есть RecyclerView. Макет всплывающего окна:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="6mm"
android:paddingTop="1mm"
app:layout_constraintTop_toTopOf="parent"
app:tabGravity="fill"
app:tabIndicatorColor="@android:color/black"
app:tabIndicatorGravity="bottom"
app:tabIndicatorHeight="1dp"
app:tabPaddingStart="0dp"
app:tabSelectedTextColor="@android:color/black"
app:tabTextAppearance="@style/AppTheme.TabLayout.Tab"
app:tabTextColor="@color/colorTabSecondary" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/tabs" />
</androidx.constraintlayout.widget.ConstraintLayout>
Фрагменты имеют такой же макет:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackground">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Как изменить высоту PopupWindow, когда я помещаю новые элементы в просмотрщик фрагментов фрагментов?
Обновление: Просто используйте PopupWindow.update()