【发布时间】:2019-03-13 14:03:15
【问题描述】:
我有一个带有左右填充的 viewpager,用于显示 viewpager 左右页面的预览。
viewPager.setPadding(30,0,30,0);
viewpager 的内容是从here 借来的缩放布局。 所以问题是,每当我从 viewpager 缩放布局时,唯一可见的缩放是在顶部和底部。由于填充,左右缩放不可见。
缩放视图被限制在 viewpager 填充内。我需要视图在没有任何填充或边界的情况下缩放全屏。
这些是我正在尝试的代码 sn-ps
activity_reader.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,但缩放时仍然存在一侧填充
【问题讨论】:
标签: android android-viewpager zooming scale pinchzoom