imageview

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

心已入冬 提交于 2019-11-26 04:38:27
问题 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

ImageView scaling TOP_CROP

社会主义新天地 提交于 2019-11-26 04:38:04
问题 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

How to Make an ImageView in Circular Shape? [duplicate]

南笙酒味 提交于 2019-11-26 03:53:55
问题 This question already has answers here : How to make an ImageView with rounded corners? (46 answers) Closed 6 years ago . I want to do something like that. This is a list view row with name and the image of user. I have done some searching and have done the image circular,but not the perfect solution. Any help will be helping me. my code added to the Image Loader class public Bitmap processBitmap(Bitmap bitmap) { int pixels = 0; if (mRound == 0) pixels = 120; else pixels = mRound; Bitmap

Scale Image to fill ImageView width and keep aspect ratio

隐身守侯 提交于 2019-11-26 03:36:35
问题 I have a GridView . The data of GridView is request from a server. Here is the item layout in GridView : <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:background=\"@drawable/analysis_micon_bg\" android:gravity=\"center_horizontal\" android:orientation=\"vertical\" android:paddingBottom=\"@dimen/half_activity_vertical_margin\" android:paddingLeft=\"@dimen/half_activity_horizontal

Show GIF file with Glide (image loading and caching library)

南楼画角 提交于 2019-11-26 03:28:26
问题 I try to show a GIF image as loading placeholder in image view - with Glide Library: Glide.with(context) .load(ImageUrl()) .placeholder(R.drawable.loading2) .asGif() .crossFade() .into(image); I try to show this file loading2.gif but get this error : Error:(54, 86) error: cannot find symbol method asGif() How can I show GIF file with Glide in a imageView? 回答1: The above answer didn't work for me. The below code works. ImageView imageView = (ImageView) findViewById(R.id.imageView);

Replace selector images programmatically

孤街醉人 提交于 2019-11-26 03:26:26
I have an ImageView that has a drawable image resource set to a selector. How do I programmatically access the selector and change the images of the highlighted and non-highlighted state? Here is a code of selector: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/iconSelector"> <!-- pressed --> <item android:state_pressed="true" android:drawable="@drawable/btn_icon_hl" /> <!-- focused --> <item android:state_focused="true" android:drawable="@drawable/btn_icon_hl" /> <!-- default --> <item android:drawable="@drawable

Replace selector images programmatically

百般思念 提交于 2019-11-26 03:24:58
问题 I have an ImageView that has a drawable image resource set to a selector. How do I programmatically access the selector and change the images of the highlighted and non-highlighted state? Here is a code of selector: <?xml version=\"1.0\" encoding=\"utf-8\"?> <selector xmlns:android=\"http://schemas.android.com/apk/res/android\" android:id=\"@+id/iconSelector\"> <!-- pressed --> <item android:state_pressed=\"true\" android:drawable=\"@drawable/btn_icon_hl\" /> <!-- focused --> <item android

How to load an ImageView by URL in Android? [closed]

人盡茶涼 提交于 2019-11-26 03:12:26
问题 How do you use an image referenced by URL in an ImageView ? 回答1: From Android developer: // show The Image in a ImageView new DownloadImageTask((ImageView) findViewById(R.id.imageView1)) .execute("http://java.sogeti.nl/JavaBlog/wp-content/uploads/2009/04/android_icon_256.png"); public void onClick(View v) { startActivity(new Intent(this, IndexActivity.class)); finish(); } private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { ImageView bmImage; public DownloadImageTask

Get Bitmap attached to ImageView

烂漫一生 提交于 2019-11-26 02:39:55
问题 Given ImageView image = R.findViewById(R.id.imageView); image.setImageBitmap(someBitmap); Is it possible to retrieve the bitmap? 回答1: Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap(); 回答2: This will get you a Bitmap from the ImageView . Though, it is not the same bitmap object that you've set. It is a new one. imageView.buildDrawingCache(); Bitmap bitmap = imageView.getDrawingCache(); === EDIT === imageView.setDrawingCacheEnabled(true); imageView.measure(MeasureSpec

Android get image from gallery into ImageView

若如初见. 提交于 2019-11-26 02:33:25
问题 I\'m trying to add a photo from galery to a ImageView but I get this error: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/1 }} to activity {hotMetter.pack/hotMetter.pack.GetPhoto}: java.lang.NullPointerException This is my code: Intent intent = new Intent(); intent.setType(\"image/*\"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent,\