imageview

Get associated image (Drawable) in ImageView android

最后都变了- 提交于 2019-12-09 10:07:12
问题 i set a image to a imageview control in android: iv.setImageResource(R.drawable.image1); i want to get this associated Drawable, looks like: Drawable myDrawable = iv.getImageResource(); //wrong thanks! 回答1: You can get the drawable like Drawable myDrawable = iv.getDrawable(); You can compare it with a drawable resource like if(iv.getDrawable()==getResources().getDrawable(R.drawable.image1)){ //do work here } 回答2: Define the Drawable first. Drawable myDrawable = getResources().getDrawable(R

Display images from protected folder

时光毁灭记忆、已成空白 提交于 2019-12-09 07:45:31
I have a protected folder within Yii and I'm looking to display some of those images within the site. I've tried the following code and it works within the site/index controller in that it returns just the image I wanted. However when I tried to separate the code it didn't work. Any help is appreciated. Model public function getImage() // will take file identifier as @param { $imageID = '2562584569'; // will eventually be dynamically assigned $image = Images::model()->find('tmp_name=:id', array('id' => $imageID)); $dest = Yii::getPathOfAlias('application.uploads'); $file = $dest .'/' . $image-

Converting image url to bitmap quickly

不打扰是莪最后的温柔 提交于 2019-12-09 06:22:20
问题 I need to display the list of images from api in the list page. For that i used two approaches. First Approach: By converting the url to byte array and then converting it into bitmap.Please find the below code.. URL imageUrl = new URL(url); URLConnection ucon = imageUrl.openConnection(); InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(500); int current = 0; while ((current = bis.read()) != -1) { /* This

Elevation not working for ImageView

我的梦境 提交于 2019-12-09 05:04:16
问题 Elevation for ImageView is not working. I declared ImageView in XML like this: <ImageView android:id="@+id/image" android:layout_width="100dp" android:layout_height="50dp" android:elevation="10dp" android:src="@drawable/youtube" /> What else should I do for elevation to work properly for ImageView? 回答1: The elevation shadow is derived from the background drawable of a View. If your ImageView has no background, you'll see no shadow. If you want to change that behavior, you need to build your

Android convert base64 encoded string into image view

限于喜欢 提交于 2019-12-09 04:18:10
问题 I want to convert base64 encoded string into bitmap so i can put it in image view, but getting error like D/skia(7490): --- decoder->decode returned false and bitmap returns null value My code is: byte[] imageAsBytes = Base64.decode(imageData); image.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)); 回答1: Firts you have to check that the string you want to decode is vaild and has the intended value to be decoded and to do so, you can do something like below:

Round cornered ImageView supporting background color in Android?

依然范特西╮ 提交于 2019-12-08 21:07:42
I want to do a round corner ImageView . But I want it have background color (e.g., #000 ). With current solutions (either build an extended round corner view or paint a round corner bitmap) the background property will spoil the effect, as the view will be in a black rectangle (see the below image). Is it possible to realize such a view that the background zone is also round cornered? PS, why I want a background color: I allow users to upload non-square images but my image view zone is square, so I want a color to "align" them (see the below image - I want the red part to be round). Rounded

How to set a clickable region for an ImageView?

匆匆过客 提交于 2019-12-08 20:15:29
I have 2 ImageViews which have AnimationDrawable backgrounds to animate a box opening and closing when you click on it. The 2 images are slightly overlapping (the transparent area) so they can be closer together. The problem this is causing is that I am unable to click on regions of the 1st image where the 2nd image (transparent area) is overlapping. Is there a way to set a clickable region of an ImageView? I don't think that you can "define a clickable region on an ImageView" like you would do in HTML with a map. IMO the best you could do is draw a canvas on top of your ImageView with the

How to put 50% for width

这一生的挚爱 提交于 2019-12-08 19:36:20
问题 I have a LinearLayout in horizontal orientation and 2 ImageView and I want to make that ImagesView fill 50% of the screen on width, to work in every cellphone or tablet with diferent sizes. Something like this: +-------------+ |_____________| | | | | 50% | 50% | | | | |-------------| | | +-------------+ Best so far: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill

How can I align my ImageView with my TextView in a LinearLayout?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 19:14:15
问题 I have the following ImageView and TextView: Here is the XML: <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/headerLinearLay" android:orientation="horizontal"> <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/avatarImageView"></ImageView> <TextView android:layout_height="wrap_content" android:id="@+id/usernameTextView" android:text="TextView" android:layout

My images changing during scroll in listview android

吃可爱长大的小学妹 提交于 2019-12-08 16:00:34
问题 In last week, i just try to resolve this problem. see every similar questions and i don't know why, solutions don't work for me. I have a list view and each item has an image view. when clicked on image view , i want to change image resource. well. all done. but when scrolling, image resources change. my full code is: public class CustomBaseAdapter extends BaseAdapter { Context context; ArrayList<String> items; public CustomBaseAdapter(Context context,ArrayList<String> items){ this.context =