Apply backgroundTint to background drawable for API 19

ema3272 picture ema3272 · Dec 5, 2015 · Viewed 15.7k times · Source

The backgroundTint is correctly applied on API 23, but not on API 19. How can I get the drawable tinted for API 19 and below?

                    <Button
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:id="@+id/AbResetBtn"
                    android:background="@android:drawable/stat_notify_sync"
                    android:backgroundTint="@color/button_material_light" />

Of course my Activity extends AppCompatActivity.

Answer

DoruChidean picture DoruChidean · Feb 16, 2017

This worked for me on API19 device, support lib v7

layout

<Button
    android:id="@id/btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/label"
    style="@style/Button"
    />

styles

<style name="Button" parent="Base.TextAppearance.AppCompat.Button" >
    <item name="backgroundTint">@color/fab_bg</item>
</style>