android - Setting alpha to bitmap in XML drawable not working on API Level 20 and below -


i setting alpha bitmap in xml (selector) , working fine on api level 23 , 22 , 21 doesn't work on api level 20 , below api levels.

<selector xmlns:android="http://schemas.android.com/apk/res/android">  <!--state selected--> <item android:drawable="@drawable/item_selected" android:state_selected="true"/> <!--state normal-->  <item >     <bitmap android:src="@drawable/item_selected" android:alpha="0.6"/> </item> 

edit

please suggest me alternatives using xml.

setting alpha programmatically work. try this.

i have tried selector background of imageview:

<imageview     android:id="@+id/imageview"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:background="@drawable/select"     /> 

my java code :

imageview = (imageview)findviewbyid(r.id.imageview);     imageview.setalpha(0.5f);     imageview.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              toast.maketext(mainactivity.this, ""+imageview.isselected()                     , toast.length_short).show();             if(imageview.isselected())             {                 imageview.setselected(false);                 // set alpha 0.5                 imageview.setalpha(0.5f);             }             else {                 imageview.setselected(true);                 // set alpha 1                 imageview.setalpha(1f);             }         }     }); 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -