RepoPilot

How do their APIs compare?

About baseflow/photoview · 2 messages · last activity 8/15/2026

Question

How do their APIs compare?

RepoPilot

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: PhotoView is a drop-in subclass of ImageView, used exactly like a normal ImageView in XML — <com.github.chrisbanes.photoview.PhotoView .../> — with setImageResource()/setImageDrawable() [README.md:L45-L52].
  • Gesture/zoom engine: the real logic lives in PhotoViewAttacher, which implements onTouch/onLayoutChange to drive a Matrix-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], plus setOnDoubleTapListener, 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 PhotoView is just an ImageView, it can be instantiated per-page inside a PagerAdapter.instantiateItem [sample/src/main/java/com/github/chrisbanes/photoview/sample/ViewPagerActivity.java:L49-L55], though the README calls out that ViewGroups using onInterceptTouchEvent (like ViewPager/DrawerLayout) can throw exceptions with it, requiring a workaround like HackyDrawerLayout [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 custom PagerSlidingTabStrip-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 id materialviewpager_pagerTitleStrip, rather than passing listener objects [README.md:L326-L353].
  • Later versions added HeaderDesign for programmatic header color/image control and a displayToolbarWhenSwipe attribute [README.md:L499-L504].

Summary of the contrast

| Asp

Want to ask your own question?

Open chat for baseflow/photoview

Public Q&A. Generated by RepoPilot from the actual source of baseflow/photoview. AI answers can be incomplete or stale — verify before relying on them.