imageview

How to get the width and height of an Image View in android?

左心房为你撑大大i 提交于 2019-11-26 17:55:33
In my code I have an Image View in my XML layout and I keep changing the source image for this in my code. Now I want to know the width and height of the generated image each time. I tried using getWidth() , getHeight(), getMeasuredWidth(), and getMeasuredHeight() , but they all return 0. How can I get this? Veer Where you calling getWidth() and getHeight() on ImageView? If you calling from onCreate() in activity, it won't work. You need to wait for activity window to attached and then call getWidth() and getHeight() on ImageView. You can try calling getWidth() and getHeight() from

Universal-Image-Loader | SSLHandshakeException: Handshake failed

半世苍凉 提交于 2019-11-26 16:38:48
问题 I have a ListView with some content (TextViews, ImageView...) in the items. I'm using UIL by Nostra to load the images in the items but some of them fail to load. This is what do I get, when i call Log.v(String.valueOf(failReason.getCause()); : 11-16 23:52:20.447: V/javax.net.ssl.SSLHandshakeException: Handshake failed(17467): failz 11-16 23:52:20.657: V/NativeCrypto(17467): SSL handshake aborted: ssl=0x15fd758: Failure in SSL library, usually a protocol error 11-16 23:52:20.657: V

ImageView fit without stretching the image

℡╲_俬逩灬. 提交于 2019-11-26 16:15:39
问题 is it possible that my ImageView will fit to all screen sizes without the image look stretched? i tried all scale types changing it to background and src with fill_parent > wrap_content but still. if the image is not smaller it just looks stretched.. example: <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="centerInside" android:adjustViewBounds="true" android:background="@drawable/background" /> <ImageView android:layout_width="fill_parent

Can't use srcCompat for ImageViews in android

徘徊边缘 提交于 2019-11-26 16:04:39
问题 I'm using the Design Support Library 23.2. I've added these lines in my build.gradle as my Gradle Plugin is version 1.5 defaultConfig { applicationId "com.abc.xyz" minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" generatedDensities = [] } aaptOptions { additionalParameters "--no-version-vectors" } } as it's specified in here But I can't use the srcCompat attribute for my imageview. <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android

Android - ImageView: setImageBitmap VS setImageDrawable

流过昼夜 提交于 2019-11-26 15:58:16
问题 What is the difference between setImageBitmap and setImageDrawable ? I have an image which I would like to set dynamically from file. The tutorial that I followed says to convert my Bitmap to a BitmapDrawable then set it using setImageDrawable . I've notice that setting the Bitmap directly with setImageBitmap also works but I don't notice any difference. Bitmap image = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); BitmapDrawable bitmapDrawable = new BitmapDrawable(image); imageView

Trying to get the display size of an image in an ImageView

被刻印的时光 ゝ 提交于 2019-11-26 15:49:19
I'm trying to get the real size of an image displayed in an image view. Actually my image is larger than the screen and the imageview is resizing the image to diplay it. I'm looking for this new size. I've tried to override the onDraw method of the ImageView in a custom view but I'm not getting the correct height and width... public class LandImageView extends ImageView { public LandImageView( Context context ) { super( context ); } public LandImageView(Context context, AttributeSet attrs) { super(context, attrs); } public LandImageView(Context context, AttributeSet attrs, int defStyle) {

ImageView scaling TOP_CROP

情到浓时终转凉″ 提交于 2019-11-26 15:48:58
I have an ImageView which is displaying a png that has a bigger aspect ratio than that of the device (vertically speaking - meaning its longer). I want to display this while maintaining aspect ratio, matching the width of the parent, and pinning the imageview to the top of the screen. The problem i have with using CENTER_CROP as the scale type is that it will (understandable) center the scaled image instead of aligning the top edge to the top edge f the image view. The problem with FIT_START is that the image will fit the screen height and not fill the width. I have solved this problem by

Android fade in and fade out with ImageView

此生再无相见时 提交于 2019-11-26 15:46:57
I'm having some troubles with a slideshow I'm building. I've created 2 animations in xml for fade in and fade out: fadein.xml <?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:interpolator="@android:anim/accelerate_interpolator" android:duration="2000"/> </set> fadeout.xml <?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:interpolator="@android:anim/accelerate

ImageView rounded corners

时光怂恿深爱的人放手 提交于 2019-11-26 15:45:50
问题 I wanted image to have rounded corners. I implement this xml code and use this in my image view. but image overlap the shape. I am downloading the image through async task. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:radius="20dip" /> </shape> <ImageView android:id="@+id/trVouchersImage" android:layout_width="55dp" android:layout_height="55dp" android:layout_marginLeft="8dp" android

ImageView be a square with dynamic width?

依然范特西╮ 提交于 2019-11-26 15:11:30
I have a GridView with ImageViews inside. I have 3 of them for each row. I can set correctly the width with WRAP_CONTENT and scaleType = CENTER_CROP, but I don't know how to set the ImageView's size to be a square. Here's what I did until now, it seems to be ok except the height, that is "static": imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT, 300)); I'm doing it inside an adapter. The best option is to subclass ImageView yourself, overriding the measure pass: