How to make move and scale activity - android

I want the user to upload his profile picture but I want to force him to crop it before .
How can I do that ?
I try to do it from scratch but it will take a lot of time i guess , Is there any library can do the job for me ?

There are a few way to do, First and suggested way use library or handle it with android intent
com.android.camera.action.CROP
at your own
I'v use this library for a while and it's great
https://github.com/ArthurHub/Android-Image-Cropper

You can use Picasso library. It is very easy to use.
For example:
Picasso.with(mContext)
.load(url)
.centerCrop()
.resize(yourImageView.getMeasuredWidth(),yourImageView.getMeasuredHeight())
.error(R.drawable.error)
.placeholder(R.drawable.blank_img)
.into(yourImageView);

Related

Xamarin android Glide webp animation

I'm using this library (Xamarin binding library of Glide), to display Gif in my app. But i would like to display Webp animations to save some space in my app.
Glide.With(context)
.Load(url)
.Into(imageView);
But the animation is locked on the first frame and didn't played (webp animation example).
Did i miss something?
Thank you.
Regards, Samih
It's a known issue.
Right now, Glide has no built-in webp support and defaults to the system.It seems like Glide will work when you introduce some libraries that support WebP.

Scale an image in Kotlin Android Studio

I'm new to Kotlin and Java and don't know how to scale an image in an image view.
I want something like this: MyImageView.setHeight(300)
I don't want to distort the image.
Thanks in advance!
This solution might be overkill for your current question, but if you have to show images in your app, I recommend using an image handling library such as Picasso or Glide.
If you are to use Picasso, add it to your dependencies by adding the following line to your gradle files :
dependencies {
implementation 'com.squareup.picasso:picasso:2.71828'
}
Then in your Kotlin file, when you are about to load the picture onto an ImageView,
do it using Picasso using the following lines :
Picasso
.get()
.load(imageUrl)
.fit()
.centerInside()
.into(imageView)
Yes, I agree with rgv. Use an image handling library, preferably Picasso. It can reduce a lot of hardwork and also, the result is better than what you would have got by scaling image manually.

Download image as thumbnail in listview adapter android

I have a decent android app which is using two fragments one of them is Listfragment. And my question is, can I use Asynctask to download the image and compress it to a thumbnail and then assign it to an imageview ? (Imagine there are like 100 items in ListView). Or is this even possible to call the asynctask each time ?
You don't need to reinvent the wheel. There are libraries which already can download, cache and resize image for you. For instance Picasso:
Picasso
.with(context)
.load(url)
.resizeDimen(width, height)
.centerCrop()
.error(R.drawable.error_img);
.into(placeholder);
For this task, I would strongly recommend the use of an external library.
There are many to choose from that can be used to download, display and cache images from an online source. As many of these libraries have been developed for many years, they are usually going to be better than any bespoke code you write.

How to use LruBitmapPool in Glide?

I am using Glide for displaying images in a listview.
How can I use LruBitmapPool to reduce GC (Garbage Collection)?
There is no sample around.
Glide Page :
https://github.com/bumptech/glide
Glide uses the LruBitmapPool automatically so you don't normally need to worry about it. It looks like you posted an issue on Glide's Github page, so let's follow up there: https://github.com/bumptech/glide/issues/326.

Does Picasso apply resize options during fetch()?

I am referring to this post Getting Picasso to pre-fetch forthcoming images where #BillMote uses fetch() with centerCrop() and further options:
Picasso.with(getApplicationContext())
.load(url)
.resizeDimen(R.dimen.article_image_preview_width, R.dimen.article_image_preview_height)
.centerCrop()
.fetch();
Will Picasso honor such options at all, or will Picasso save the image straight to the cache so these options are ignored and should be used later when the image is pulled from the cache and viewed?
It still isn't clear to me (and after 6 months I haven't found any documentation where this was clearly defined [I admit I haven't investigated into this either]) if Picasso applies any such options before saving the file to the cache, or repeatedly every time it displays an image.
Something like centerCrop() makes no sense to me in above statement, because the size of the target ImageView isn't clear at this point. This might be different for resizeDimen(), but I stil doubt Picasso will apply the dimensions because JakeWharton once said in a post that Picasso relies on okhttp for image caching.
Can anybody shed light please.

Categories

Resources