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:

  • Is there a better way of debugging OpenGL than calling glGetError after each command?
  • AppRTC server returns html instead of Json
  • How to put variable inside string-resources?
  • Android Jack mockito alternative
  • CyanogenMod: Translate a Project
  • Android close app on back button
  • <
            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:

    How to get the selected index of a RadioGroup in Android
    MediaMetadataRetriever.getFrameAtTime() returns only first frame
    IntelliJ/Android Studio: remove unnecessary use of &#039;this.&#039;
    How to create a popup window in android?
    A firewall for Android with VpnService. Responses are delivered, but a SocketTimeoutException is thr...
    Android NDK C++ &#039;wstring&#039; support
  • Android 6 EditText.setError not working correctly
  • How is application orientation (landscape or portrait) locked?
  • Get battery level only once using Android SDK
  • Distinguish between Tablet and Smart phone on ICS
  • How to combine Navigation Drawer and Spinner
  • How can I set the color of android rating bar's stroke? (Not the color of the stars but the BORDER)
  • 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.