Ste*_*ynx 9 layout android android-5.0-lollipop
这就是我设置按钮的方式.
<Button
android:id="@+id/button_login"
style="@style/ButtonStyle"
android:text="@string/button_login" />
Run Code Online (Sandbox Code Playgroud)
这是我在values文件夹上的样式.
<style name="ButtonStyle" parent="ButtonStyleBase" />
<style name="ButtonStyleBase">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">@dimen/padding</item>
<item name="android:textSize">@dimen/font_regular</item>
<item name="android:textColor">@color/text_regular</item>
<item name="android:background">@drawable/shape_clickable</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是我在values-v21文件夹上的样式
<style name="ButtonStyle" parent="ButtonStyleBase">
<item name="textAllCaps">false</item>
<item name="android:textColor">#000000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但是按钮上的文本总是大写的.如果我直接在按钮上设置它,它将恢复正常.我更改了颜色以查看是否正在使用api 21的样式,它是,在api 21上按钮文本颜色变为黑色.我知道默认主题将textAllCaps设置为按钮的true,因为谷歌认为它会超级-cool,但不应该优先考虑我的风格吗?
编辑:从不,我忘了在风格上写"android:".
Gal*_*lya 22
我有同样的问题,这对我有用:
<style name="Theme.CustomTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:textAppearanceButton">@style/CustomTheme.ButtonTextAppearance</item>
</style>
<style name="CustomTheme.ButtonTextAppearance" parent="@style/Base.TextAppearance.AppCompat.Button">
<item name="textAllCaps">false</item>
<item name="android:textAllCaps">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.