Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply backgroundTint to background drawable for API 19

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.

like image 921
ema3272 Avatar asked Dec 05 '15 16:12

ema3272


Video Answer


2 Answers

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>
like image 181
DoruChidean Avatar answered Oct 07 '22 09:10

DoruChidean


I know its little bit old question but you don't need to create a style element even.

Just use AppCompatButton from the support library with app: namespace.

<android.support.v7.widget.AppCompatButton android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:id="@+id/AbResetBtn"
                    android:background="@android:drawable/stat_notify_sync"
                    app:backgroundTint="@color/button_material_light" />
like image 25
Paresh Dudhat Avatar answered Oct 07 '22 09:10

Paresh Dudhat