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);
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
Post a Comment