Efr*_*vAV 5 fonts android button
将我的活动的父级更改Activity为AppCompatActivity,更改按钮上的字体.例如,Remove- > REMOVE.对于其他Vews,字体没有改变.
为什么按钮上的字体会发生变化?如何恢复原始字体?
按钮:
<Button
android:id="@+id/buttonAddProduct"
tools:text="Remove"
android:layout_width="match_parent"
android:textSize="13dp"
android:layout_weight="1"
style="@style/btns_blue_big" />
Run Code Online (Sandbox Code Playgroud)
样式:
<style name="btns_text_big">
<item name="android:textSize">@dimen/text_size_big</item>
<item name="android:textColor">@color/colorMainWhite</item>
</style>
<style name="btns_lo_big" parent="btns_text_big">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">48dp</item>
</style>
<style name="btns_blue_big" parent="btns_lo_big">
<item name="android:background">@drawable/button_dialog_positive_shape</item>
</style>
Run Code Online (Sandbox Code Playgroud)
由于Google的Material Design主题,这种变化发生了.
基本上,当你改变你Activity对AppCompatActivity,你必须也更改应用的主题,从延长Theme.AppCompat.此更改会使每个视图的设计与主题相匹配.
以下是Holo主题和AppCompat主题之间的示例:
如您所见,AppCompat主题中按钮的默认实现使用全部大写,因此您需要更改它们.
一个简单的解决方法是在你的样式xml中添加这些:
<style name="MyAppTheme" parent="Theme.AppCompat">
<item name="buttonStyle">@style/MyAppTheme.Button</item>
<item name="android:buttonStyle">@style/MyAppTheme.Button</item>
</style>
<style name="MyAppTheme.Button" parent="Base.Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
825 次 |
| 最近记录: |