Android Webview layouting SINGLE_COLUMN - android

I have a quite big problem with the layout of my WebView. I'm downloading content from an RSS collector site, including the article content.
This content may contain pictures or YouTube videos or whatever else. Downloading is not the problem, but rather displaying it.
The pictures will probably be too wide to fit the screen. This is not a problem - I can resolve that by setting the LayoutAlgorithm to SINGLE_COLUMN.
_webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
However, using SINGLE_COLUMN creates a problem for YouTube videos. They are resized in width, but not in height - resulting in the WebView displaying only a black picture instead of the video. There is no way of playing the video like this.
I can resolve this as well by setting the LayoutAlgorithm to NORMAL or NARROW_COLUMNS - however, that results in the pictures not being resized to the screen size as I'd like, and I have to scroll right/left in order to see the whole picture (which does not work very well because I have the WebView in a horizontal PageAdapter).
I can assume this may be the reason SINGLE_COLUMN is deprecated (developer.android.com). However, NARROW_COLUMNS just does not do what I'm expecting it to.
Does anyone have any idea how to resolve this issue?

Look at my answer here, the problem is that LayoutAlgorithm.SINGLE_COLUMN - is deprecated now.
The problem is that images in your html have fixed width - you have to fix it - setting max-width

Related

Load a very large Image in android

Assumes I have a picture, it very large images or other sets of content where you are only looking at small bits at a time, because you can start seeing your content without having to load it all into memory at once.
In iOs we can use CATiledLayer to repeatedly draw tiles to fill up view’s background
In Android I can see Google Map, It also load each part of map when you scroll but I don't understand what is solution of them.
I want know what is the solution same CATiledLayer in Android or other to load very large Image
you can actually scale down the bitmap according to the size of the image view.
Don't give wrap_content in width and height try to give a relative width and height.
use
ImageView.getheight()
ImageView.getWidth()
get the size and load according to it
see this link
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html#read-bitmap
You can use a library load images efficiently and manage caching them instead of downloading them again. I suggest Picasso or Glide. This tutorial compares between them and explains few features.
I hope it's useful.

How to cope with jitter when using Android-Universal-Image-Loader in a ListView?

I'm using Android-Universal-Image-Loader in a ListView of mine and I'm trying to find the best solution to following:
using resetViewBeforeLoading is necessary or else I get the same image in my ConvertViews, but this causes jitter, unless..
I use PauseOnScrollListener which is otherwise great, except that it shows a blank in some ConvertViews even for images that are already downloaded (I'm using memory and disk caches), so it's confusing to the user who sees a blank for an image they saw only 2 swipes ago
So it seems that I can't get an instant image load (for already-downloaded images) on scroll without jitter, even for images in memory, is this about right? Is there a better or more standard way to do this? (Vertical list-view showing screen-width images, sort of like the Instagram app, which does it buttery-smooth)
Otherwise, is there a way to lengthen the number of convertViews in my ListView to prevent unnecessarily aggressive re-use?
Thanks in advance

Trying to get a handle on displaying an image with zoom and pan

I've read a ton of posts, and tried a few of the suggested solutions, but not having much luck.
I have a ViewPager which is happily displaying text views.
I now want to enhance it to also support ImageViews. The images may be in a wide variety of shapes and sizes, so I need to give the user the ability to zoom and pan in order to focus on any area.
NB. I do not necessarily want pinch zoom, as the pinch-zoom libraries I've tried (eg. https://github.com/jasonpolites/gesture-imageview/blob/master/main/src/com/polites/android/GestureImageView.java and http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/) seem to work intermittently, and crash with out-of-memory. So rather than complicate the solution with gesture detection, I'm happy to put a slider control above the view to achieve the zoom UI.
I'm struggling to get a handle on what is an appropriate view hierarchy to achieve this (eg. do I need a ScrollView or is panning a feature within the ImageView), and should I be scaling the bitmap, or resizing the view?
Any suggestions on what view components I need to use would be much appreciated.
Should I even be using ImageView? I've seen some answers suggesting that a WebView is a better starting point.
My instinct is that what I'm trying to do should be pretty basic, and require no more than the right view hierarchy and view config settings. It seems too simple to require a custom ImageView class, but of course I might be wrong.
Should I even be using ImageView? I've seen some answers suggesting that a WebView is a better starting point.
This is the way I solved it in the end. I simply wrapped the image filename in some HTML and gave it to a webview.
This gave me the following specific benefits:-
The detailed user behaviour (eg. zoom rate, pinch sensitivity, availability of an on screen control) were consistent with the browser, and so familiar to the user's muscle memory
I don't need to depend on any third party code
Since it's core Android, it's probably better tested against edge cases (eg. one library I considered didn't support landscape)
I don't need to worry about out of memory situations with Bitmap processing
In the future, I might want to provide "web page" as one of the items in my ViewPager anyway, so one stone, two birds.
Here is the code I ended up with.
File imgFile = new File(FILESDIR,FILENAME);
if(imgFile.exists()){
WebView wv = (WebView) rootView.findViewById(R.id.imageView1);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setDisplayZoomControls(true);
String html = ("<html><img src='"+imgFile.getName()+"'></html>" );
wv.loadDataWithBaseURL("file://"+imgFile.getAbsolutePath(),
html,
"text/html",
"utf-8",
"");
}
You need to use GestureDetectors. Google has excellent sample interactiveChart for this, see https://android.googlesource.com/platform/development/+/master/samples/training/InteractiveChart and http://developer.android.com/training/gestures/scroll.html

Android - Scrollable ImageView Lag

I am using the Scrollable ImageView by Egor Andreevich found here.
Although I have successfully managed to insert this into my app, the issue I'm having is that my image is very laggy. The image I'm using is 1.63 mb and 3713x3329 in dimension. If I use a smaller image that is both small in dimension and size, then it works perfectly.
The post you are referring to seems to be an introduction of scrolling images in an ImageView, and not a complete implementation. I would direct you to PhotoView for a more complete implementation.

Android Webview can't show jpg images with more than 3000 pixels height

I am using a WebView in an Android Activity to show a simple html who has a single jpg inside. When the jpg height is smaller than 3000 pixels, there is no problem, it show perfectly, but when the jpg is above 3000 pixels, it does not show. Can be this a limitation? Or memory issue? I am using Android 2.3 to test.
Your problem is that you're using a huge image, so the device can't handle that much data.
In order to display it properly and nicely mi advice is to use an html table wich each cell containing a slice of the image.
The browser will just render the parts of the table being displayed, so your image will be loaded properly.
I used this approach on a project and worked perfectly.
Regards.

Categories

Resources