简体   繁体   中英

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?

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

try to use

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM