RajSharma RajSharma - 2 months ago 15
Android Question

How to change the Alpha of an ImageView in android

I have five

ImageViews
declared in the
layout
file. All of them have src attribute set to some image.

I want to give some effect something like changing the alpha value when you click on an image to the images.

Here is my code

<ImageView
android:id="@+id/imageViewNews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/news" />

<ImageView
android:id="@+id/imageViewBookmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/bookmark" />

Answer

In XML use

android:alpha="" alpha between 0 to 1 

In code use

imageView.setAlpha(int);

Similar Question

Comments