在API 27上,Android提供了多种不同的样式,可以通过在XML布局文件或Java代码中设置来实现。以下是一些常见的样式及其代码示例:
xmlns:app="http://schemas.android.com/apk/res-auto"
然后可以在具体的View中使用AppCompat样式,例如:
或者在Java代码中设置样式:
Button button = new Button(context, null, R.attr.buttonStyle);
xmlns:android="http://schemas.android.com/apk/res/android"
然后可以在具体的View中使用Material样式,例如:
或者在Java代码中设置样式:
Button button = new Button(context, null, R.style.Widget_MaterialComponents_Button);
然后可以在具体的View中使用自定义样式,例如:
或者在Java代码中设置样式:
Button button = new Button(context, null, R.style.MyCustomButtonStyle);
这些是在API 27上实现不同样式的一些常见方法和代码示例。可以根据实际需求选择适合的样式来美化Android应用程序。