Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button BackgroundTint not working with AppCompat v23

I'm trying to use AppCompat v23 so that I have full Button coloring using BackgroundTint.

I have added compile 'com.android.support:appcompat-v7:23.0.+' to my app's build.gradle file.

I have my app theme set with android:theme="@style/AppTheme" in AndroidManifest.xml

In styles.xml I have:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
    </style>
</resources>

I'm not trying to override anything, I'm just trying to get the base theme to work.

I am using public class LandingActivity extends AppCompatActivity in my main activity declaration.

Finally, within the layout I have android:backgroundTint on a Button to set a color in colors.xml.

On a device running 5.0 the colors work perfectly. On 4.0 devices there is no coloring on the buttons. It's the default grey.

I'm sure that I'm missing something, but I have no idea what it is. Are there any other steps that I need to take to allow the AppCompat library to work its magic?

like image 641
Nathan Tornquist Avatar asked Sep 01 '15 15:09

Nathan Tornquist


1 Answers

Instead of <Button android:backgroundTint="~" />,

try to use

<android.support.v7.widget.AppCompatButton xmlns:app="http://schemas.android.com/apk/res-auto" app:backgroundTint="~"/>

like image 188
Renan Arceno Avatar answered Sep 29 '22 09:09

Renan Arceno