How do their APIs compare?
How do their APIs compare?
About baseflow/photoview · 2 messages · last activity 8/15/2026
The two libraries solve very different problems, so their APIs aren't really comparable feature-for-feature — but here's how each is shaped, and where they intersect (both target Android View/ViewGroup widgets used inside scrollable containers).
baseflow/photoview — a zoomable ImageView
Its API is a single-widget, listener-driven surface:
- Core widget:
PhotoViewis a drop-in subclass ofImageView, used exactly like a normal ImageView in XML —<com.github.chrisbanes.photoview.PhotoView .../>— withsetImageResource()/setImageDrawable()[README.md:L45-L52]. - Gesture/zoom engine: the real logic lives in
PhotoViewAttacher, which implementsonTouch/onLayoutChangeto drive aMatrix-based transform — scale, pan, fling [photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java:L338-L358]. - State accessors:
getScale(),getScaleType(),getDisplayRect(),setScale(...),setZoomable(...)/isZoomable()[photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java:L319-L358, L268-L272]. - Listener callbacks for observing state changes rather than polling:
OnMatrixChangedListener.onMatrixChanged(RectF)[photoview/src/main/java/com/github/chrisbanes/photoview/OnMatrixChangedListener.java:L9-L19], plussetOnDoubleTapListener,setOnScaleChangeListener,setOnSingleFlingListener[photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java:L256-L265], and tap callbacks (onPhotoTap,onViewTap,onOutsidePhotoTap) fired from the double-tap gesture detector [photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java:L202-L226]. - ViewPager interop: because
PhotoViewis just anImageView, it can be instantiated per-page inside aPagerAdapter.instantiateItem[sample/src/main/java/com/github/chrisbanes/photoview/sample/ViewPagerActivity.java:L49-L55], though the README calls out that ViewGroups usingonInterceptTouchEvent(likeViewPager/DrawerLayout) can throw exceptions with it, requiring a workaround likeHackyDrawerLayout[README.md excerpt].
So the API surface is: one custom ImageView, a matrix/gesture attacher, and a handful of listener interfaces for zoom/tap/matrix events.
florent37/materialviewpager — a composite ViewPager+header widget
Its API (from the README, since no Java source was included in the retrieved chunks) is XML-attribute + declarative configuration driven, not gesture/matrix driven:
- Core widget:
<com.github.florent37.materialviewpager.MaterialViewPager .../>wraps a ViewPager plus an animated/static header image [README.md:L274-L297]. - Configuration is via custom XML attributes rather than Java setters shown in the excerpts, e.g.
app:viewpager_animatedHeaderImage="true|false"to toggle a Ken Burns animated header vs. a static ImageView header [README.md:L274-L297],app:viewpager_headerAlpha="0.6"[README.md:L536-L542],app:viewpager_pagerTitleStrip="@layout/my_tabs"to swap in a customPagerSlidingTabStrip-based tab bar [README.md:L326-L359]. - Extensibility via composition: to customize tabs, you build your own layout (e.g. using
com.astuetz.PagerSlidingTabStrip) and reference it by idmaterialviewpager_pagerTitleStrip, rather than passing listener objects [README.md:L326-L353]. - Later versions added
HeaderDesignfor programmatic header color/image control and adisplayToolbarWhenSwipeattribute [README.md:L499-L504].
Summary of the contrast
| Asp
Want to ask your own question?
Open chat for baseflow/photoviewPublic Q&A. Generated by RepoPilot from the actual source of baseflow/photoview. AI answers can be incomplete or stale — verify before relying on them.