I have made an Imageview which contain drawable vector image and I want check which drawable image is present in Imageview but after trying many conditions unable to check which drawable is present in ImageView, I have try this
addbookimg.drawable.constantState ==
this.resources.getDrawable(R.drawable.ic_baseline_add_a_photo_24,this.theme).constantState
and also tried this
addbookimg.drawable.constantState ==
this.resources.getDrawable(R.drawable.ic_baseline_add_a_photo_24).constantState
Related
I got a school project where i need to make a cooking app, I struggle with programmaticaly importing an image to get a preview of the dish in my class.
The images are located in the drawable-v24 folder but i can't figure out ou to get the right path to it.
I want it to be a Drawable to create an image view in my layout.
package com.example.projet_info0306;
import android.graphics.drawable.Drawable;
public class Recette {
private String nom;
private Etape[] steps;
private Drawable Demo;
public Recette(String n,Etape[] e,String PathImg,) {
nom=n;
steps=e;
Demo= Drawable.createFromPath("#drawable/"+PathImg+".png");
}
}
If you want to show the Image in your App, just go to your activity_main.xml, add an ImageView to the layout and give it an ID.
You can now either link up the image statically in the XML by unsing the android:src tag or you can do it programatically by using:
Imageview imageview;
imageview = findViewByID(R.id.[yourID]);
imageview.setDrawable(R.drawable.[yourDrawable]);
NOTE: The code snippet you showed is in a normal Class not in an Activity. If you want to add one just go to your projects folder and right click on App. Android Studio will then lets you create an Activity. Or if your are not that far in the process, just create a new project and add an Activty from the beginning.
Is there any way to add multiple checkbox at different location over an image in imageview and that checkbox will stay at its relative position while zooming
No. You can not add Views (CheckBox is a View element) inside Views that are not ViewGroups (ImageView is a View but not a ViewGroup). ViewGroups are Views such as LinearLayout, RelativeLayout etc.
Yet, you can arrange your items (ImageView and multiple CheckBoxes) inside a RelativeLayout or FrameLayout which allow you to put Views in such a way, that they can overlap.
I'm following the instructions for adding stylekit images to storyboards by adding an object, setting it's class to stylekit and then right click dragging to the UIImage from the stylekit object - however I'm not seeing the images show up in UIImageView preview in the storyboard. The image is there when I run the code however.
Is there a different series of steps I need to take? I'm using ios9 xcode 7.
Interface Builder doesn’t allow previewing this kind of connections. To see the image in IB, you will need to subclass the view, mark it as #IBDesignable and override drawRect method, where you call the StyleKit drawing method.
I create an imageView and resize it. After applying a color effect it gets resized back to original dimensions.
Envi: Oracle JDK 7 (1.7.0_51-b13) and Oracle JDK 8 (8b124-0~webupd8~0)
final ImageView imageView = new ImageView(image);
imageView.setPreserveRatio(true);
imageView.setFitHeight(image.getHeight() * imageViewScale);
imageView.setFitWidth(image.getWidth() * imageViewScale);
Resizing works fine until now. But colorizing it resizes back to embedded image dimensions.
final Blend effect = new Blend(BlendMode.SRC_ATOP, new ImageInput(imageView.getImage()), new ColorInput(0, 0, imageView.getImage().getWidth(), imageView.getImage().getHeight(), color));
imageView.setEffect(effect);
Even a later resetting does not work
imageView.setFitHeight(height);
imageView.setFitWidth(width);
I already tried the approach of the ImageViewPane in https://javafx-jira.kenai.com/browse/RT-21337 but it could not handle the case as well.
Any ideas?
how to create a custom layout View in Android So that I can put an ImageView and a TextView under it .
thanks in advance.