Is there anyway to set alpha on a drawable sitting within an editText as a drawableLeft?
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/edittext_middle_bg"
android:id="@+id/birthday_overlay"
android:editable="false"
android:focusable="false"
android:padding="10dp"
android:hint="Birthday"
android:textColorHint="#bbbbbb"
android:drawablePadding="10dp"
android:drawableLeft="@drawable/ic_cake_black_24dp"/>
I got the icon from the material icon library by Google. The icon is where alpha is 1 (so full black). I want to make it slightly grey by making alpha 0.5 for example.
I guess I can use GIMP / Photoshop to change the alpha but would prefer to use android to do this programmatically.
4
Answers
So this is eventually what I did to achieve my desired outcome.
Use this method. Pass the argument as your drawableLeft from the EditText. This works for <= API 16 and > API 16.
I search many and found this unique – for my research – solution:
I make with a CountDownTimer, work good.
And after in a countdowntimer, I blink the
leftCompoundDrawable
setting the:Work Good, Need a little adjust of countDownInterval and Alpha Value Step, check when alpha is minor to 0 or more to 255 (Alpha in Drawables is from 0 to 255) and change step alpha to + or –, but is easy to adjust for good look.
The CountDownTimer is very usseful in some cases.