Top Related Projects
Implementation of ImageView for Android that supports zooming, by various touch gestures.
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon
Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.
A simple and customizable Android full-screen image viewer 一个简单且可自定义的Android全屏图像浏览器
Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻
Quick Overview
PhotoView is an Android library that provides a customizable ImageView for photo viewing with zooming and panning capabilities. It offers smooth transitions, gesture support, and integration with various image loading libraries, making it ideal for photo gallery applications and image-centric user interfaces.
Pros
- Smooth and responsive zooming and panning functionality
- Easy integration with popular image loading libraries like Glide and Picasso
- Customizable attributes for tailoring the view to specific app requirements
- Support for both single and multi-touch gestures
Cons
- Limited documentation and examples for advanced use cases
- Potential performance issues with very large images or numerous PhotoViews in a single layout
- Lack of built-in image loading capabilities, requiring integration with third-party libraries
Code Examples
- Basic PhotoView implementation:
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
- Loading an image into PhotoView using Glide:
import com.bumptech.glide.Glide
val photoView: PhotoView = findViewById(R.id.photo_view)
Glide.with(this)
.load("https://example.com/image.jpg")
.into(photoView)
- Adding a scale change listener:
photoView.setOnScaleChangeListener { scaleFactor, focusX, focusY ->
Log.d("PhotoView", "Scale changed to: $scaleFactor")
}
- Programmatically zooming to a specific scale:
photoView.setScale(2.5f, true)
Getting Started
To use PhotoView in your Android project, follow these steps:
- Add the dependency to your app's
build.gradle
file:
dependencies {
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
}
- Add the JitPack repository to your project's
build.gradle
file:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
-
Use the PhotoView in your layout XML or create it programmatically in your Activity or Fragment.
-
Load images into the PhotoView using your preferred image loading library.
Competitor Comparisons
Implementation of ImageView for Android that supports zooming, by various touch gestures.
Pros of PhotoView (Baseflow)
- Written in Kotlin, offering modern language features and better null safety
- More recent updates and active maintenance
- Supports Jetpack Compose for modern Android UI development
Cons of PhotoView (Baseflow)
- Less comprehensive documentation compared to the bm-x version
- Fewer stars and forks on GitHub, potentially indicating a smaller community
Code Comparison
PhotoView (bm-x):
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);
photoView.setMaximumScale(6);
PhotoView (Baseflow):
val photoView = findViewById<PhotoView>(R.id.photo_view)
photoView.setImageResource(R.drawable.image)
photoView.maximumScale = 6f
Both libraries provide similar functionality for displaying and manipulating images in Android applications. The bm-x version is written in Java and has been around longer, with more stars and forks on GitHub. It offers extensive documentation and examples.
The Baseflow version, being newer and written in Kotlin, provides a more modern approach with potential performance improvements and better integration with recent Android development practices. However, it has a smaller community and less comprehensive documentation.
Choose based on your project's requirements, preferred language, and need for long-term support or cutting-edge features.
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon
Pros of FrescoImageViewer
- Built on top of Fresco library, providing efficient image loading and caching
- Supports zooming and panning with smooth animations
- Customizable overlay views for additional information or controls
Cons of FrescoImageViewer
- Limited to Fresco library, which may not be suitable for all projects
- Less actively maintained compared to PhotoView
- Fewer customization options for gestures and transitions
Code Comparison
PhotoView:
PhotoView photoView = findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);
photoView.setScaleType(ImageView.ScaleType.CENTER_CROP);
FrescoImageViewer:
new ImageViewer.Builder<>(this, images)
.setStartPosition(startPosition)
.setOverlayView(customView)
.show();
PhotoView offers a more straightforward implementation for basic image viewing, while FrescoImageViewer provides a builder pattern for configuration and supports multiple images out of the box.
Both libraries offer image viewing capabilities with zooming and panning, but they differ in their approach and underlying technologies. PhotoView is more lightweight and flexible, while FrescoImageViewer leverages the Fresco library for efficient image loading and caching. The choice between the two depends on project requirements and existing dependencies.
Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.
Pros of subsampling-scale-image-view
- Efficient memory usage for large images through subsampling
- Supports very large images (up to 20,000x20,000 pixels)
- Smooth scrolling and zooming performance
Cons of subsampling-scale-image-view
- Limited animation support compared to PhotoView
- Lacks some advanced features like rotation gestures
- May require more initial setup for basic functionality
Code Comparison
PhotoView:
PhotoView photoView = findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);
subsampling-scale-image-view:
SubsamplingScaleImageView imageView = findViewById(R.id.imageView);
imageView.setImage(ImageSource.resource(R.drawable.image));
Both libraries offer easy-to-use image loading, but subsampling-scale-image-view requires an additional step of wrapping the image source.
PhotoView provides a more straightforward API for basic image viewing, while subsampling-scale-image-view offers better performance for large images at the cost of slightly more complex setup.
subsampling-scale-image-view is ideal for applications dealing with high-resolution images or maps, where memory efficiency and smooth scrolling are crucial. PhotoView, on the other hand, might be preferable for simpler image viewing needs with more animation options.
A simple and customizable Android full-screen image viewer 一个简单且可自定义的Android全屏图像浏览器
Pros of imageviewer
- More recent updates and active development
- Supports video playback in addition to images
- Offers a wider range of customization options for UI elements
Cons of imageviewer
- Larger library size, potentially impacting app performance
- Less comprehensive documentation compared to PhotoView
- Steeper learning curve for implementation due to more complex API
Code Comparison
PhotoView:
PhotoView photoView = findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);
imageviewer:
val imageViewer = ImageViewer.Builder(activity, images)
.setStartPosition(0)
.setBackgroundColorRes(R.color.black)
.show()
Summary
PhotoView is a simpler, more lightweight library focused solely on image viewing with pinch-to-zoom functionality. It's easier to implement but offers fewer features.
imageviewer provides a more comprehensive solution with support for both images and videos, along with additional UI customization options. However, it comes with a larger footprint and may require more effort to integrate into projects.
Both libraries serve their purposes well, with PhotoView being ideal for basic image viewing needs and imageviewer better suited for more complex media viewing requirements.
Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻
Pros of BigImageViewer
- Supports multiple image loading libraries (Fresco, Glide, and custom implementations)
- Handles very large images efficiently with tiling and subsampling
- Provides smooth animations for transitions and gestures
Cons of BigImageViewer
- More complex setup and configuration compared to PhotoView
- Larger library size due to additional features and dependencies
- May have a steeper learning curve for basic use cases
Code Comparison
PhotoView:
PhotoView photoView = findViewById(R.id.photo_view);
Glide.with(this).load(imageUrl).into(photoView);
BigImageViewer:
BigImageView bigImageView = findViewById(R.id.big_image_view);
BigImageViewer.initialize(FrescoImageLoader.with(this));
bigImageView.showImage(Uri.parse(imageUrl));
Summary
PhotoView is simpler to implement and suitable for basic image viewing needs, while BigImageViewer offers more advanced features and flexibility for handling large images and complex scenarios. PhotoView has a smaller footprint and easier integration, but BigImageViewer provides better performance for very large images and supports multiple image loading libraries.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PhotoView å¾çæµè§ç¼©æ¾æ§ä»¶
ä¸ä¸ªæµç çphotoview
ææå¾
注æ
ç±äºfacebookçFrescoå¾çå è½½ç»ä»¶æå è½½åºæ¥çdrawableå¾ç并éçå®çdrawable,æ æ³ç´æ¥è·åå¾ççå®å®½é«,ä¹æ æ³ç´æ¥ååºImageMatrixçåæ¢ï¼ ä¸æ ¹æ®Frescoææ¡£çä»ç»,å¨åç»ççæ¬ä¸,DraweeViewä¼ç´æ¥ç»§æ¿èªView,æææä¸èèæ¯æFrescoã 对äºå ¶ä»ç¬¬ä¸æ¹å¾çå è½½åºå¦Glide,ImageLoader,xUtilsé½æ¯æ¯æç
使ç¨
1.Gradleæ·»å ä¾èµ (æ¨è)
dependencies {
compile 'com.bm.photoview:library:1.4.1'
}
(æè ä¹å¯ä»¥å°é¡¹ç®ä¸è½½ä¸æ¥ï¼å°Info.javaåPhotoView.java两个æ件æ·è´å°ä½ ç项ç®ä¸ï¼ä¸æ¨è)
2.xmlæ·»å
<com.bm.library.PhotoView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/bitmap1" />
3.java代ç
PhotoView photoView = (PhotoView) findViewById(R.id.img);
// å¯ç¨å¾ç缩æ¾åè½
photoView.enable();
// ç¦ç¨å¾ç缩æ¾åè½ (é»è®¤ä¸ºç¦ç¨ï¼ä¼è·æ®éçImageViewä¸æ ·ï¼ç¼©æ¾åè½éæå¨è°ç¨enable()å¯ç¨)
photoView.disenable();
// è·åå¾çä¿¡æ¯
Info info = photoView.getInfo();
// ä»æ®éçImageViewä¸è·åInfo
Info info = PhotoView.getImageViewInfo(ImageView);
// ä»ä¸å¼ å¾çä¿¡æ¯ååå°ç°å¨çå¾çï¼ç¨äºå¾çç¹å»åæ¾å¤§æµè§ï¼å
·ä½ä½¿ç¨å¯ä»¥åç
§demoç使ç¨
photoView.animaFrom(info);
// ä»ç°å¨çå¾çååå°æç»å®çå¾çä¿¡æ¯ï¼ç¨äºå¾çæ¾å¤§åç¹å»ç¼©å°å°åæ¥çä½ç½®ï¼å
·ä½ä½¿ç¨å¯ä»¥åç
§demoç使ç¨
photoView.animaTo(info,new Runnable() {
@Override
public void run() {
//å¨ç»å®æçå¬
}
});
// è·å/设置 å¨ç»æç»æ¶é´
photoView.setAnimaDuring(int during);
int d = photoView.getAnimaDuring();
// è·å/设置 æ大缩æ¾åæ°
photoView.setMaxScale(float maxScale);
float maxScale = photoView.getMaxScale();
// 设置å¨ç»çæå
¥å¨
photoView.setInterpolator(Interpolator interpolator);
å ³äº
è¥éå°ä½¿ç¨ä¸çé®é¢ï¼è¯·å
ç¿»çIssuesï¼å¤§é¨åé®é¢æ¯å·²ç»æ人æåºè¿çã(å¦#9,#5)
è¥æ²¡æ¾å°ç¸å
³çé®é¢ï¼å¯ä»¥å
å¨Issuesä¸æåºï¼è¿æ ·ä»¥ä¾¿å
¶ä»äººéå°åæ ·é®é¢æ¶å¯å¿«éæ¾å°çæ¡ã
è¥é¿æ¶é´æªåå¤ï¼å¯é®ä»¶ç»æbmme@vip.qq.com
çæ¬
v1.4.0
- å¢å 对æ®éImageViewçæ¯æï¼å¯éè¿PhotoViewçéææ¹æ³getImageViewInfo(ImageView)ä»ä¸ä¸ªæ®éçImageViewä¸è·åInfoï¼åç §ImageViewActivity
- æ·»å é¿æäºä»¶ççå¬ï¼setOnLongClickListener()
- æé«å¾ç缩æ¾å°å±å¹è¾¹ç¼çæ åµä¸æ»å¨çæµç æ§
- æ°å¢get/setAnimaDuring() get/setMaxScale è·å设置å¨ç»çæç»æ¶é´åå¾çæ大缩æ¾åæ°
- éè¿setInterpolatorå¯è®¾ç½®å¨ç»æå ¥å¨
v1.3.6
- å¢å å¾ççæ转åè½
- çæ¬å·å½åæ¹å
v2.0.7
- 宽é«å±æ§å¯ä»¥è®¾ç½®ä¸ºwrap_contentï¼æ·»å 对adjustViewBoundså±æ§çæ¯æ
- ä¿®å¤æäºæ åµä¸ä¼éªå¨
- å¢å 对ScaleType.FIT_START,FIT_END对animaFromçæ¯æ
v2.0.0
- æ·»å animaTo,animaFromæ¹æ³ï¼æ¯æå¾çç¹å»æ¾å¤§ç¼©å°æµè§åè½
- æ·»å enable()ådisenable() æå¼åå ³é触æ¸ç¼©æ¾æ¹æ³ï¼é»è®¤æå¼ (å½æ®éImageView使ç¨çæ¶åå»ºè®®å ³é触æ¸ç¼©æ¾åè½)
- æ¯æææScaleTypeå±æ§
v1.0
Top Related Projects
Implementation of ImageView for Android that supports zooming, by various touch gestures.
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon
Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.
A simple and customizable Android full-screen image viewer 一个简单且可自定义的Android全屏图像浏览器
Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot