Apply backgroundTint to background drawable for API 19

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>

You need to use android support library 22.1+ to use AppCompatButton http://android-developers.blogspot.se/2015/04/android-support-library-221.html

But unfortunately you will not be able to do this in the xml.

In the onCreate of your activity, to the following:

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        AppCompatButton v = (AppCompatButton) findViewById(R.id.mybutton);
        ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{0xffffcc00});
        v.setSupportBackgroundTintList(csl);
    }
}

More info here: Lollipop's backgroundTint has no effect on a Button

Tip: maybe you will be able to do everything in the xml using app:backgroundTint="@color/button_material_light", but I didn't tested.

--EDIT--

Check @ema3272 second comment for the full solution


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" />