2

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" />
halfer
  • 19,471
  • 17
  • 87
  • 173
RajSharma
  • 1,931
  • 3
  • 21
  • 34

2 Answers2

2

In XML use

android:alpha="" alpha between 0 to 1 

In code use

imageView.setAlpha(int);

Similar Question

Community
  • 1
  • 1
K Guru
  • 1,272
  • 2
  • 15
  • 35
  • possible duplicate of http://stackoverflow.com/questions/4931071/android-and-setting-alpha-for-image-view-alpha – Apurva Feb 05 '15 at 10:04
0

the simplest way is to use ViewCompat.setAlpha

  ViewCompat.setAlpha(imageViewInstace, alpha);

where alpha is a float between 0 and 1

Blackbelt
  • 152,872
  • 27
  • 286
  • 297