Android - 覆盖text,小,中,大的外观

时间:2016-12-21 19:42:24

标签: android styles

我正在尝试覆盖我的Android应用程序中的默认文本外观

这是我的styles.xml但它不起作用(对于textView,picker等......)

<?xml version="1.0" encoding="UTF-8"?>
<resources>

  <style name="newTheme" parent="newTheme.Base"></style>

  <style name="newTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>

  </style>

  <style name="TextAppearance.Large" parent="newTheme">
    <item name="android:textSize">11sp</item>
  </style>

  <style name="TextAppearance.Medium" parent="newTheme">
    <item name="android:textSize">11sp</item>
  </style>

  <style name="TextAppearance.Small" parent="newTheme">
    <item name="android:textSize">11sp</item>
  </style>


</resources>

1 个答案:

答案 0 :(得分:5)

<style name="TextAppearance.Large" parent="TextAppearance.AppCompat.Large">
  <item name="android:textSize">11sp</item>
</style>

<style name="TextAppearance.Medium" parent="TextAppearance.AppCompat.Medium">
  <item name="android:textSize">11sp</item>
</style>

<style name="TextAppearance.Small" parent="TextAppearance.AppCompat.Small">
  <item name="android:textSize">11sp</item>
</style>

请注意,要查看您的更改,您必须在布局中引用它们

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="@style/TextAppearance.Small"/>

或以风格

引用它们
<style name="newTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>

    <item name="android:textAppearanceLarge">@style/TextAppearance.Large</item>
    <item name="android:textAppearanceMedium">@style/TextAppearance.Medium</item>
    <item name="android:textAppearanceSmall">@style/TextAppearance.Small</item>

</style>