Android imageview change tint to simulate button click

happydude’s answer is the most elegant way to handle this but unfortunately (as pointed out in the comments) the source code for ImageView only accepts an integer (solid colour). Issue 18220 has been around for a couple years addressing this, I’ve posted a workaround there that I’ll summarize here: Extend ImageView and wrap drawableStateChanged() with … Read more

How to check which current image resource is attached to ImageView in android xml?

Hi please have a try with this as follows if (regProfile.getDrawable().getConstantState() == getResources().getDrawable( R.drawable.ivpic).getConstantState()) { Toast.makeText(_con, “Image is ivPic”, Toast.LENGTH_LONG).show(); // new RegisterAsyntaskNew().execute(); } else { Toast.makeText(_con, “Image isn’t ivPic”, Toast.LENGTH_LONG).show(); // new RegisterAsyntask().execute(); } please use .getConstantState() to compare visit http://developer.android.com/reference/android/graphics/drawable/Drawable.html http://developer.android.com/reference/android/graphics/drawable/Drawable.ConstantState.html EDIT: .getResources().getDrawable(imageResource) Is deprecated in API21, so I changed Jitesh Upadhyay’s answer. … Read more

How to set a ripple effect on textview or imageview on Android?

Ref : http://developer.android.com/training/material/animations.html, http://wiki.workassis.com/category/android/android-xml/ <TextView . . android:background=”?attr/selectableItemBackgroundBorderless” android:clickable=”true” /> <ImageView . . . android:background=”?attr/selectableItemBackgroundBorderless” android:clickable=”true” />

How to use selector to tint ImageView?

If you’re in API 21+ you can do this easily in XML with a selector and tint: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_activated=”true”> <bitmap android:src=”https://stackoverflow.com/questions/19500039/@drawable/ic_settings_grey” android:tint=”@color/primary” /> </item> <item android:drawable=”https://stackoverflow.com/questions/19500039/@drawable/ic_settings_grey”/> </selector>

How To Display Border To Imageview?

You can create a resource (layer drawable xml) for your ImageView‘s “border” (actually background), and declare in your theme that the ImageView‘s background resource is the drawable xml. If you need this “border” to be changed based on the ImageView‘s state (focused, selected, etc.), then you should create more layer drawables, and put them together … Read more