Reputation: 1971
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" />
Upvotes: 2
Views: 2558
Reputation: 1302
In XML use
android:alpha="" alpha between 0 to 1
In code use
imageView.setAlpha(int);
Upvotes: 2
Reputation: 157437
the simplest way is to use ViewCompat.setAlpha
ViewCompat.setAlpha(imageViewInstace, alpha);
where alpha
is a float between 0 and 1
Upvotes: 0