The title is pretty self-explanatory, I have a button for which I call setStateListAnimator(null);
. I've also registered for an OnClickListener
callback. The problem is whenever I call setStateListAnimator(null)
I don't get callback for onClick()
.
<Button android:id="@+id/urlSubmittButton"
android:layout_below="@id/editLyout"
android:layout_width="150dp"
android:layout_height="45dp"
android:text="Add"
android:layout_marginTop="10dp"
android:textSize="18sp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:padding="5dp" />
and in my Fragment
:
urlSubmitButton = (Button) mView.findViewById(R.id.urlSubmittButton);
urlSubmitButton.setClickable(true);
urlSubmitButton.setEnabled(true);
urlSubmitButton.setOnClickListener(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
urlSubmitButton.setStateListAnimator(null);
}
As you can see, I tried setting the Button
clickable and enabled, it doesn't change the behavior. However commenting simply that line of code works the charm.
Is this intended behavior for API 24? Because so far I've only been able to reproduce this issue in API 24 device. If not, then is there any other way of stopping stateListAnimator
which causes a water-drop-ripple-effect in Button
when clicked?
If not, then is there any other way of stopping
stateListAnimator
which causes a water-drop-ripple-effect inButton
when clicked?
First of all, I don't think stateListAnimator
is somehow connected with ripple effect. Ripple is just a background set to the Button
, whereas stateListAnimator
specifies what animation to perform based on the current state of the view. See states in StateListDrawable
.
In order to completely hide the ripple effect apply this to the style of your activity:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="selectableItemBackground">@null</item>
<item name="selectableItemBackgroundBorderless">@null</item>
</style>