我有一个带有左右填充的 viewpager,用于显示 viewpager 左右页面的预览。
viewPager.setPadding(30,0,30,0);
viewpager的内容是借用的zoomlayouthere。
所以问题是,每当我从视图页面缩放布局时,唯一可见的缩放位于顶部和底部。由于填充,缩放在左侧和右侧不可见。
Screenshot before zooming
Screenshot after zooming
缩放视图仅限于视图页面填充内。我需要视图缩放全屏,没有任何填充或边界。
这些是我正在尝试的代码片段
活动阅读器.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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:layout_width="match_parent"
android:layout_height="match_parent">
<ViewPager
android:id="@+id/reader_pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000"/>
</FrameLayout>
每个页面.xml
<?xml version="1.0" encoding="utf-8"?>
<com.test.poc.widgets.ZoomLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/zoom_layout">
<RelativeLayout
android:id="@+id/img_holder"
android:transitionName="pager"
android:background="#FFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/page_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/a_four"
android:layout_weight="1"
android:scaleType="fitXY"
/>
</RelativeLayout>
</com.test.poc.widgets.ZoomLayout>
缩放视图后,当我松开手指时,视图应该平滑地移动到全屏视图页面。
尝试将clipToPadding设置为false,但缩放时填充的一侧仍然存在