As you all see in attachment, android imageview got distortion after being completely downloaded with using coding of following link Load images from web and caching.
here is my imageview tag and original image resolution is 850x315.
<ImageView
android:paddingTop="10dip"
android:paddingBottom="5dip"
android:id="#+id/idThumb"
android:layout_width="match_parent"
android:layout_height="70dp"
android:contentDescription="#string/app_name"
android:scaleType="centerCrop"
android:src="#drawable/no_image" />
Please check me why this ImageView cannot fetch original resolution of image from URL and got blur.!
gotta use WebView instead of ImageView will fulfilled what I want.
Related
Today I received a complaint for an app that I made. Basically, the problem is that I have an ImageView which loads an image from the resources directory, but sometimes, the image is not loaded and a white space is displayed instead. The only complaint comes from Sony Xperia Z3 with the Android version 5.1.1. The drawable is added only for xhdpi, but I know that if needed Android scales it to the corresponding resolution. Do you have any ideas why this could take place since I wasn't able to reproduce the bug? Also, here's my ImageView code but I'm sure that there is no problem.
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginBottom="#dimen/padding_medium"
android:background="#drawable/green_logo"
android:scaleType="fitCenter"
android:contentDescription="#null" />
Why do you use background for ImageView? Use android:src="#drawable/image".
I am using Parse (I know it's a dying service) to fetch and store images for me. Included in these are authenticated Facebook user's profile pictures. The pictures are 50x50. If I download the image locally, throw it in the drawables folder, and load it via XML (android:src="#drawable/dummy") this is the result. It's what I want:
But when I load the image from Parse and load it into the CircularImageView, this is the result:
As you can see, my head shrunk :(
Here's some code:
The CircularImageView in XML:
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/main_list_profile"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:src="#drawable/dummy"/>
Loading the Image via Picasso Library
Picasso.with(mContext).load(carItem.getUserPosted().getParseFile("profileThumb").getUrl()).noFade().into(viewHolder.profileImage);
Libraries used:
Picasso
CircularImageView
Parse (Baas)
Picasoo has method called resize you can use it like that:
Picasso.with(context).load(img_url)
.resize(img_width, img_heghit).into(image_view);
Creating vector images in Photoshop (for transparent backgrounds). When I add them as the image source for my ImageButtons, and run the app, the image displays with a white background.
Can't find any useful info on why the images are not coming out transparent through the app.
Are there some additional steps/coding required to make vector images work properly? I can't see why.
Example code, as requested:
<ImageButton
android:id="#+id/btnGameUp"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="#drawable/arrowright"
android:adjustViewBounds="false"
android:clickable="true"
android:cropToPadding="false"
android:padding="0dp"
android:scaleType="fitXY"
android:layout_marginLeft="270dp"
android:layout_marginTop="260dp" />
No one came to help us, but we managed to find the solution on our own after hours of crying and holding each other for comfort.
In the layout xml file, you need to add the following line to each vector object:
android:background="#android:color/transparent"
That's it! Tested and working perfectly. Hope this helps someone.
My linearLayout backgroud is losing is patch 9 effet after the imageView is load from a dynamic Url
the only way to fix the problem is to use holder.imgView.setScaleType(ImageView.ScaleType.FIT_XY);
but i don't want to stretch the image at the same time
<LinearLayout
android:id="#+id/llPatch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/testt1"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageRecette"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="0dp"
android:src="#drawable/tartare" />
</LinearLayout>
9-patch images are compiled with the project (from your res folder).
You can see how a compiled 9-patch looks like if you add one to a project, build it (the project) and look in bin/res/[where your image is at]/[image name].9.png
So you can't load a 9-patch image (with the lines on the sides) from a url.
You can however upload a compiled 9-patch to your server, download it and use it as specified here:
https://stackoverflow.com/a/10639923/876603
I use an ImageView control as shown:
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/imgHangMan"
android:src="#drawable/hang0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
The above code displays the image in the Graphical Layout preview of the xml file. But on launching the app, I see no image. Also, changing the image using
imgHangMan = (ImageView)findViewById(R.id.imgHangMan);
imgHangMan.setImageResource(R.drawable.hang1);
This piece of code also does not work either. The image files are in .gif format and are in the drawable folder.
Any pointers ?
Natively ImageView doesnot support animated image. You have two options to show animated gif file
1) Use VideoView 2) Use ImageView. But Split the gif file into several parts and then apply animation to it.
Try this link-playing-gif-animation you will get the desired result.
Try this
image.setImageDrawable(getResources().getDrawable(R.drawable.hang1));
User this :
http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html
Go by this.