为旧 OS 版本设置通用按钮样式
setting a common button style for older OS versions
我正在为较旧的 android 版本设置通用按钮样式,但此代码不适用于 Kitkat,除了制作另一个布局资源文件之外,我是否可以提供一些特定样式并解决此问题?
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:buttonStyle">@style/RobotoButtonStyle</item>
</style>
// here is my custom button style
<style name="RobotoButtonStyle" parent="Base.TextAppearance.AppCompat.Button">
<item name="android:fontFamily">@font/roboto_regular</item>
<item name="android:textAlignment">center</item>
<item name="fontFamily">@font/roboto_regular</item>
<item name="android:textColor">@color/colorWhite</item>
<item name="android:background">@drawable/button_curved</item>
<item name="android:textAllCaps">false</item>
</style>
这些用于旧版本的 Android
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="buttonStyle">@style/RobotoButtonStyle</item>
</style>
<style name="RobotoButtonStyle" parent="Base.TextAppearance.AppCompat.Button">
<item name="android:fontFamily">@font/roboto_regular</item>
<item name="android:textAlignment">center</item>
<item name="fontFamily">@font/roboto_regular</item>
<item name="android:textColor">@color/colorWhite</item>
<item name="android:windowBackground">@drawable/button_curved</item>
<item name="android:textAllCaps">false</item>
</style>
我正在为较旧的 android 版本设置通用按钮样式,但此代码不适用于 Kitkat,除了制作另一个布局资源文件之外,我是否可以提供一些特定样式并解决此问题?
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:buttonStyle">@style/RobotoButtonStyle</item>
</style>
// here is my custom button style
<style name="RobotoButtonStyle" parent="Base.TextAppearance.AppCompat.Button">
<item name="android:fontFamily">@font/roboto_regular</item>
<item name="android:textAlignment">center</item>
<item name="fontFamily">@font/roboto_regular</item>
<item name="android:textColor">@color/colorWhite</item>
<item name="android:background">@drawable/button_curved</item>
<item name="android:textAllCaps">false</item>
</style>
这些用于旧版本的 Android
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="buttonStyle">@style/RobotoButtonStyle</item>
</style>
<style name="RobotoButtonStyle" parent="Base.TextAppearance.AppCompat.Button">
<item name="android:fontFamily">@font/roboto_regular</item>
<item name="android:textAlignment">center</item>
<item name="fontFamily">@font/roboto_regular</item>
<item name="android:textColor">@color/colorWhite</item>
<item name="android:windowBackground">@drawable/button_curved</item>
<item name="android:textAllCaps">false</item>
</style>