Android Glide without resizing imageview - android

I've started an app where I'm getting images from a RESTful server in response to the user clicking on another component on the screen. I've set it up so that it gets the data back, creates a byte array and displays that on the screen - all good.
However I've learnt that this may have memory leaks and the best way to load images is with glide. I've got the simple glide working but it has problems. Specifically when I reload an image onto an image view the component shrinks to a height of zero and then resizes again. How can I say to Glide - keep the component the same size during the transition? Crossfade doesn't work and I can't see anything that can do this.
EDIT
The code with the glide is as follows:
Glide.with(this)
.load(Base64.decode(image, Base64.DEFAULT))
.into((ImageView) findViewById(R.id.cutoutImageView));
The image variable is a string containing the images retrieved from a RESTful service.
The XML defining the imageview is as follows:
<ImageView
android:id="#+id/cutoutImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/annotatedImageView"
android:layout_marginLeft="10px"
android:layout_marginTop="10px"
android:background="#color/colorPrimary"
android:padding="1dp"/>
Note that I can't hardcode the size of the image view because I don't know what size image I'll be getting from the RESTful service until I get it. I do know that once I get one image then the subsequent images will all be the same size though.
Another issue is that glide wants to scale the iamge - I don't I want to show the image at the size I get it. How do I do that?

Related

Load 8000px png drawable Android Scrollable Image

I am really trying to figure out which is the best way of loading a huge image in Android ImageView( or some other view extending ImageView).
I am aware of OOM issues with Android framework when working with bitmaps but still I need to implement the following requests:
horizontal scrollable imageview
must load a huge 8000px (keeping original image quality so no downsample) width and device height png image from drawble-nodpi in it and to be fluent while scrolling it without preloads or lag(recyclerview will have blinks so it is a no go I tried that)
I am thinking at a customview extending imageview and something to decode only current scrolled region from that bitmap but I am stuck here
avoid oom
also does a pdf viewer library be better than using huge png from performance point of view? I need the picture preloaded on app start not lazy loaded

Android - Using Picasso in order to load an image for a game?

I have used both Picasso and Glide in order to load images asyncronously in grids with images coming from the phone's external memory and in order to download photos from the Internet.
But now for my Android game in the first screen I need to display an image below a title (the image takes up all available height). Then the user taps on a specific part of the image and the game starts.
The image content is a drawable resource.
So, for this specific use (a TextView and an ImageView below it which takes up all the remaining space), what should I do:
-Specify the image as ImageView's src property.
-Use an image loading library, such as Picasso or Glide
What do you suggest and why?
Thank you.
EDIT: The image would be static, a static drawable resource.

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.

Why Picasso loads image faster if Placeholder is not used Android?

I used picasso as image library for my application. Images were loading a bit slowly so i decided to remove placeholder and it started loading faster.
How come if placeholder is not there its loading faster. But problem is if I remove placeholder. Before loading image it squeezes that area and once image loads it takes proper area filled with image.
My Imageview code below:
<com.wallie.imagview.SquareImageView
android:id="#+id/imageone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#drawable/border_image_view"
android:padding="1dp" />
Picasso code i used earlier (loads image a bit slower ):
Picasso.with(context).load(url)
.placeholder(R.drawable.image_loading)
.into(imageView);
Picasso code i used now (loads image faster):
Picasso.with(context).load(url)
.into(imageView);
But problem is it squeezes space for image without placeholder and my spinner for all images get in one place.

Android Volley with Image Caching

Currently I'm working with an application where one activity holds a list view with image and text for each row. I'm downloading the images using the volley. When the list view item is clicked the app will switch to a another activity with a detail view where a large version of the clicked image will show. For the both time I'm using NetworkImageView.
Images are loaded in the list view with caching. But the problem appeared on the detailed view. The images are showing from the previously loaded cache with low resolution. I want to load a good resolution image on detailed view which will cache the image separately for large view.
For the both screen image url are same. How to do that ?
Thanks in advance.
First thing is a bit obvious - make sure you images are at the wanted quality.
If that's the case, you'll probably want to load the image "manually" using the ImageLoader class, as the NetworkImageView by default, optimizes the size of the Bitmap it creates to be the size of the view itself. So what happens is, you first load the thumbnail view which is small, and the saved Bitmap is created in that size instead of the original image size. Then, when the bigger view requests the same image, the cached version is returned which is a small Bitmap, and the view scales it up, creating the low-res appearance.
Try using ImageLoader.get() with the width and height appropriate to the bigger view in the detail screen.
The other alternative is to load 2 versions of the same image.

Categories

Resources