在viewpager2内缩放照片



我试图在ViewPager2内使用PhotoِDarweeView。当我想在水平上放大照片时,它不会放大,而是ViewPager2滑动。

activity_media_view:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
tools:context=".ui.MediaTopicActivity">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="@+id/title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/header"
tools:background="@drawable/one"
tools:layout_height="300dp" />
<!-- other views -->
</androidx.constraintlayout.widget.ConstraintLayout>

fragment_photo:

<?xml version="1.0" encoding="utf-8"?>
<me.relex.photodraweeview.PhotoDraweeView 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" />

我通过为我的viewPager2启用nestedScrolling来解决这个问题

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true" />

最新更新