AppCompatButton backgroundTint API < 21

I want to use ripple effects on Buttons. AppCompat v22.1 added AppCompatButton and new functionalities to AppCompat tinting.

My Layout:

  • Unable to dlopen( Cannot load library: link_image: failed to link
  • Issue with ComposeShader on Android 4.1.1
  • Android custom numeric keyboard
  • Can I have both Wi-Fi and cellular network interfaces open at the same time on Android?
  • how to use getListView() in Activity?
  • How to draw a circle inside a circle using Android xml shapes?
  • <
            android:text="Remove" />

    On my API 22 test device the ripple effect works perfectly, but i’m coding for API 11 and unfortunately backgroundTint needs API >= 21. How can i set the ripple effect to Buttons on older API versions?

    Related posts:

    RecyclerView store / restore state between activities
    Paging does not work and maybe I found the cause
    How can I see the error log (logcat) for Android in Eclipse?
    Android TextView&#039;s subscript being clipped off
    How do I handle a back-button press in a (Delphi) Android app?
    android child view ignore parent padding
  • Why might Resources.getString() intermittently return strings from the wrong locale?
  • Android ACTION_DATE_CHANGED broadcast
  • What's the difference in GCC between -std=gnu++0x and -std=c++0x and which one should be used?
  • adb unable to connect to Android-x86 in VirtualBox today
  • Remote debugging with Android emulator
  • Android layout - How to implement a fixed/freezed header and column
  • 2 Solutions collect form web for “AppCompatButton backgroundTint API < 21”

    Just use app:backgroundTint instead of android:backgroundTint, the tint will take effect below Lollipop. The reason is AppCompatActivity AppCompatDelegateImplV7 use AppCompatViewInflater to auto change Button or TextView to AppCompatButton or AppCompatTextView, then app:backgroundTint take effect.

    enter image description here

    In my project I used it, it worked.

    Ripples are not available as a build in functionality on Android <21. This is due to performance issues: devices with the new API can use the RenderThread which is not available to older devices.
    See also:

    Why are there no ripples on pre-Lollipop?
    A lot of what allows RippleDrawable to run smoothly is Android 5.0’s new RenderThread. To optimize for performance on previous versions of Android, we’ve left RippleDrawable out for now.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.