android 统一按钮样式,Android Material Design按钮样式

该博客介绍了如何解决Android应用程序的兼容性问题,通过更新支持库到25.2.0版本,使用AppCompatActivity作为基类,以及在布局文件中引入app命名空间和使用AppCompatButton,从而实现颜色和样式的兼容。
摘要由CSDN通过智能技术生成

2ef055c3386e3fa82983ce2c115d7578.png

慕村225694

最简单的解决方案第1步:使用最新的支持库compile 'com.android.support:appcompat-v7:25.2.0'第2步:使用AppCompatActivity作为父Activity类public class MainActivity extends AppCompatActivity第3步:在布局XML文件中使用app命名空间

    xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    android:layout_width="match_parent"

    android:layout_height="match_parent">第4步:使用AppCompatButton而不是Button

    android:id="@+id/buttonAwesome"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:text="Awesome Button"

    android:textColor="@color/whatever_text_color_you_want"

    app:backgroundTint="@color/whatever_background_color_you_want"/>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值