imageview

setColorFilter not working

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 21:01:47
I'm trying to implement a simple colorfilter on an imageview to turn the black image into a white image. In order to achieve that I do the following: weatherImg.setColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY); weatherImg.setImageResource(R.drawable.b_clouded_rain); I've also tried to change to color in the color filter to red and white but all of them have no effect, what am I doing wrong? As much as I hate to answer my own questions I found the problem: I should've used: weatherImg.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); It depends on what kind of filtering you want to

how to draw line on imageview along with finger in android

删除回忆录丶 提交于 2019-11-27 20:52:10
In my app I want to draw line on imageview along with finger. I want the output like the following: In this screen fish is the imageview and red lines are drawing lines. So I followed the link below to develop the app link . This is my code: public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.addphoto); btnAddPhoto=(Button)findViewById(R.id.add); btnEdit=(Button)findViewById(R.id.edit); imageView=(ImageView)findViewById(R.id.photo); btnAddPhoto.setOnClickListener(this); btnEdit.setOnClickListener(this); imageView.setOnTouchListener(this)

I want to transfer the image from one activity to another

左心房为你撑大大i 提交于 2019-11-27 20:50:28
I have to transfer the image from one activity to another. In first activity the user selects the image out of several images from scroll view and that image has to be displayed in the imageview of next activity. Help required. In your first Activity Convert ImageView to Bitmap imageView.buildDrawingCache(); Bitmap bitmap = imageView.getDrawingCache(); Intent intent = new Intent(this, NewActivity.class); intent.putExtra("BitmapImage", bitmap); In second Activity Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapImage"); Then display bitmap in ImageView. Note: this is not recommended.

How to display .gif file in imageview?

匆匆过客 提交于 2019-11-27 20:36:36
问题 My layout have lots of imageviews. I want to show .gif animated file in just one imageview. I tried Yash method (Adding gif image in an ImageView in android) but .gif file shown all layout. Other views dissappeared. I want to show all. Any idea? 回答1: Put your .gif file into res/raw folder, in your fragment or activity and than you can set gif in imageview like GifAnimationDrawable gif; try { gif = new GifAnimationDrawable(getResources().openRawResource(R.raw.download)); gif.setOneShot(false);

Zoom and Panning ImageView Android

倾然丶 夕夏残阳落幕 提交于 2019-11-27 20:34:47
问题 I have created a zoom and pan class for an ImageView. Features I am trying to create. - It pans on single finger touch and movement - It zooms and pans on two finger touch and movement For the most part this works very well. It has a slight bug when I do the following: - I pan around with one finger (Status: No problem) - I put down a second finger, zoom and pan (Status: No problem) - I release my second finger (Status: The image jumps a little) Was hoping someone could help me solve this. I

How can i use RotateAnimation to rotate a circle?

泄露秘密 提交于 2019-11-27 20:20:18
I want my circle image (ImageView) to rotate as the user touch and drag it. If the user drags it to the right, it should spin right and vice versa. Like when you spin a DJ disc, if you know what i mean. I've played around a bit with OnTouchListener and RotateAnimation but i'm getting nowhere. Any ideas? Let's assume you have ImageView mCircle which you want to rotate. You have to use RotateAnimation to rotate it. In OnTouch method determine the angle where user's finger is. For example, in your main activity do the following private ImageView mCircle; private double mCurrAngle = 0; private

Select a portion of image in ImageView and retrieve the end points of selected rectangle

不羁岁月 提交于 2019-11-27 19:33:18
I need to drag and select a portion of an image set in an ImageView and retrieve the end points of the selected rectangle without causing any modifications (such as crop). So far all I've been able to do is figure out the co-ordinates of the point where the user taps the screen. ImageView imageView = (ImageView) findViewById(R.id.imageView); imageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { //Simply displays a toast Utilities.displayToast(getApplicationContext(), "Touch coordinates : " + String.valueOf(event.getX()) + "x" +

android - How to cut some part of image and show it in imageview

喜夏-厌秋 提交于 2019-11-27 19:30:48
问题 I want to show only some part of image in imageview. See following image . Same example can be found in google+ app where you see all posts with images. Any links ,code will be helpful. Thanks 回答1: Use this code int width = bitmapOrg.width(); int height = bitmapOrg.height(); int newWidth = 200; int newHeight = 200; // calculate the scale - in this case = 0.4f float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // createa matrix for the manipulation

How to set an imageView's image from a string?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 19:19:59
I have a list of entries and some bitmap files in the res/drawable-mdpi directory. I'm trying to load the image corresponding to the string value selected from the list by generating a path string and using bitmap factory. The problem is I don't think my path is right because the bitmap is always null, even for the default image. String name = entries.get(position); String img = "res/drawable/logo_" + name.toLowerCase() + ".png"; // create the file name icon.setScaleType(ImageView.ScaleType.CENTER_CROP); // check to see if the file exists File file = new File(img); if (file.exists()){ bm =

Android - ImageView: setImageBitmap VS setImageDrawable

对着背影说爱祢 提交于 2019-11-27 19:17:44
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.setImageDrawable(bitmapDrawable); OR Bitmap image = BitmapFactory.decodeFile(imgFile.getAbsolutePath());