Reputation: 1091
i am working on Image fill color . i have a Transparent image , i need to fill color in image according to percentage of level complete , i don't have idea how to do it , can any one suggest me.
thanks in advance
Upvotes: 1
Views: 1192
Reputation: 685
To set background color for a transparent image, backgroundTint
attribute can be used.
<android.support.v7.widget.AppCompatImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/ic_star_white"
android:backgroundTint="@color/colorPrimary" />
Upvotes: 0
Reputation: 1091
thanks for help i just did in simple way , i am adjusting hight in run time of first imageview .
android:layout_width="300dp"
android:layout_centerHorizontal="true"
android:layout_height="300dp"
>
<ImageView
android:id="@+id/view"
android:layout_width="300dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:scaleType="fitXY"
android:layout_height="150dp"
/>
<ImageView
android:id="@+id/imgVie"
android:layout_width="300dp"
android:layout_centerHorizontal="true"
android:src="@drawable/masking"
android:scaleType="fitXY"
android:layout_height="300dp"
/>
Upvotes: 1
Reputation: 315
If you want to play with the opacity of your image, you are looking for the alpha parameter !
yourImageView.setAlpha(0.5) // alpha is between 0 and 1 (fully transparent/opaque)
If you want to change the color of your image, you'll have to work with ColorMatrixFilter :
ColorMatrix myColorMatrix = new ColorMatrix(new float[]{
1,0,0,RGBValR, //red value
0,1,0,RGBValG,
0,0,1,RGBValB,
0,0,0,1});
ColorMatrixColorFilter myFilter = new ColorMatrixColorFilter(myColorMatrix);
myImageView.setColorFilter(myfilter);
Upvotes: 0