java - Disable button click animation withouth setEnable(false) -


i have lienarlayout button in it. have onclicklistener on both button , linearlayout. @ point disable button , pass onclick event parent linearlayout. found out achieve setting button.setclickable(flase). works , linearlayout gets click, button's click animation still played. worse, if click on linearlayout button not drawn, buttons click animation still plays!

if knows how can achieve want, appreciate it.

p.s.: reason don't want use button.setenabled(false) because don't want button disabled. able enable / disable button's clickable state on demand. button active , other times click pass through linearlayout.

the code - xml:

<linearlayout     android:id="@+id/linearlayout"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="?android:attr/selectableitembackground">      <button         android:id="@+id/button"         style="?android:attr/buttonbarbuttonstyle"         android:layout_width="wrap_content"         android:layout_height="match_parent"         android:text="button"/>  </linearlayout> 

the code - java:

button btn = (button) view.findviewbyid(r.id.button); btn.setclickable(false); 

before click: before click during click on linearlayout: during click on linearlayout

you can give background color animation won't happen.

android:background="@android:color/white" 

when want clickable animation back, use this

typedvalue outvalue = new typedvalue(); getcontext().gettheme().resolveattribute(android.r.attr.selectableitembackground, outvalue, true); yourbutton.setbackgroundresource(outvalue.resourceid); 

this solve issue.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -