简体   繁体   中英

Use WebView or ImageView for best results?

I have 10000x10000 px large bitmap. I cut it into many images in Photoshop and made a WebView with html which contains these images. But I can't test my application on old phones, because I have an SGS 3.

My question is: is the better map for exploring results WebView or ImageView ?

If a WebView solves the problem for you, then I would use that. You won't need to design a flexible layout to hold a large number of Views , implement zooming and panning, etc. That's a substantial savings in development time. Making your app respond to clicks on the individual pieces of your large bitmap will take a bit of work since they're HTML elements, but (IMO) it's a better option than working with a large number of ImageView s.

If your question is more related to UI performance, that's harder to predict. WebView is optimized for displaying complex layouts and supporting the type of scrolling and scaling interactions that you mentioned. ImageView is a simple View that isn't trivial to extend for those types of interactions.

For my money: the WebView is best for this situation.

Another option is to use a custom view that implements pinch and zoom and supports subsampling large images and loading only the areas that are on screen. I was unable to find a suitable library so I built one. It uses BitmapRegionDecoder and therefore requires SDK 10 (Gingerbread). However, you don't need to cut the image up manually.

https://github.com/davemorrissey/subsampling-scale-image-view

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM