Android - changing ImageView drawable after scales & translate animation - android

I have an app that shows thumbnails of images presented as ImageViews. You tap on an image, it animates to fill the screen (rotating 90 degrees on the way if it's not a portrait image). Once it's full screen I want to switch the underlying bitmap in the ImageView with a higher res version that I'm downloading off the internet.
The problem is that after the ImageView has been scaled, the new bitmap image appears on top of the old one and at the size of the thumbnail.
Any ideas?

Related

carousel-layout-android library first load issue

I am using "https://code.google.com/p/carousel-layout-android/" in my android application. When it load first time images in carousel are of different sizes, when I scroll all the images till last item, then its images size becomes ok, like center image is big in size and left and right image is bit small in size.

Implementation for custom image cropping in Android

I need to implement the custom image cropping instead of using the system cropping (i.e. "com.android.camera.action.CROP"). I need to know the exact position of the cropping bounding box but this information is not retrievable if I choose to use the default cropping. Besides, the bitmap image is down sampled too much by default cropping.
The steps are as following:
Create the original size bitmap from source (using uri). The
original size is about 4000x3000 which is too big.
The user defines the crop area to extract the ROI which results in resizing of the original image to fit the ImageView. (size of ImageView is about 700x700)
Record the position of the bounding box in the ImageView.
Retrieve the cropped area from the original image and create another bitmap for it.
Resize the cropped bitmap to fit the imageview size to show it on the screen.
This approach works on my device (ZTE nuoio with Android 4.3) well. However, the app crashes on Samsung S4 with Android 4.4.4 and Note 4 while performing step 1 probably because of the out-of-memory error.
Therefore, I try to do another approach that creates the bitmap which is down sampled from the source image, rather than having the original size bitmap image.
I need to have the information of the exact position of cropped area from the original image. That is the reason why I didn't use default cropping. Could you please help me out with my case either providing
the solutions to derive the exact coordinates of the bounding box of the cropped image in the original image as a matrix.
how to solve the out-of-memory error in step 1 using the approach I mentioned above.
Or other approach to achieve image cropping with knowing the exact coordinates of cropped area form the original image.
Thank you so much.
For Crop an image and get Coordinates use library Edmodo Croper https://github.com/edmodo/cropper
For Out of memory issue you have to down scale image.

Wallpaper not scaling correctly when placing it as activity backgroung

I have a custom .png image set as my Android device's wallpaper.
As I understand it, wallpaper size should be 960x800 pixels but the Android device will only present the middle part of the image and the extra right and left parts are for when you scroll right and left on the screen. So I’ve taken a small image that I want it to be in the center of the screen (350x350) and filled the rest of the image with a black surrounding.
My problem is: I have an activity in my application that needs its background to be similar to the wallpaper (to imitate a blank activity with just a TextView presented on it).
I’m using this code to do so:
private WallpaperManager wallpaperManager;
private Drawable wallpaperDrawable;
private RelativeLayout rtemp;
rtemp = (RelativeLayout)findViewById(R.id.temp_layout);
wallpaperManager = WallpaperManager.getInstance(this);
wallpaperDrawable = wallpaperManager.getDrawable();
rtemp.setBackground(wallpaperDrawable);
But the screen appears to have the wallpaper as a whole and not just the middle part anymore (it basically shrink down the image) and it is not consistent with the regular wallpaper anymore.
Are there any suggestions on how to solve it? Is there a way to avoid image shrinking on the activity or is there a way to make the image not spread as the wallpaper screen?
Thanx a lot!
Better use FrameLayout which contains both your RelativeLayout over an ImageView. Imageview gives you the options to scale your image & some furthermore customization.

OpenGLRenderer trying to scale down bitmap - when reaching end of ViewPager

App has a ViewPager with several Fragment in it.
When user scrolls to the end of pages, there's this Android gradient effect that indicates there's no more pages (instead of iOS's bounce effect).
When this effect occurs, apps become unresponsive and frames are dropped, while in the log there these lines -
Trying to scale down bitmap for texture (2560x4544 -> 2307x4096)
Scaled bitmap has been successfully created
There's no bitmap in the app of this size and it's running on a QHD (1440 x 2560 pixels) LG G3 display, so I guess some bitmap is scaled up to fit this xxxhdpi resolution, then for some reason scaled down a bit.
Question is - why is it trying to scale down a bitmap when this effect occurs? Can this be avoided?
Is it the gradient effect rendering that is being scaled down?
It stopped when I turned off the over scroll effect (iOS's bounce equivalent). Maybe this effect is an image that's resized before shown, though I don't understand why they don't cache it, if it's true.
viewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
The problem is with loading some image in your page:
Solutions:
1. if you must load the image use a library named Picasso http://square.github.io/picasso/ to load it
2. if the image is a shape try to make the shape yourself in android.
At all costs avoid loading big images in the xml. even in the newest phones this has a big impact on performance.

Images size issue in UpdateTexture

I'm Trying to update the TextureRegion for a sprite dynamically.Following UpdateTextureExample
But the images that I have to replace with are different in size. Is there a work around for this??
The image replaced is stretched out, as the previous image was bigger in size!!

Categories

Resources