TextAppearance主题

cel*_*tis 6 android themes coding-style

我想将主题中的文本外观设置为TextAppearnance.Large.这是我在styles.xml中做的事情(我的应用程序指向我的清单中的这个主题)

<style name="myTheme" parent="android:Theme.NoTitleBar.Fullscreen">  
 <item name="android:textAppearance">@android:style/TextAppearance.Large</item>  
</style>
Run Code Online (Sandbox Code Playgroud)

问题:我的文字仍然显示得很小.

问题(S):

  • 在我的活动中尝试使用预定义的TextAppearance时,我做错了什么?即如何正确指定此TextAppearance?
  • TextSpearance.Large/Medium/Small的TextSizes在哪里定义?

Nou*_*non 5

首先,将属性声明为

<item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
Run Code Online (Sandbox Code Playgroud)

但是,在主题中声明文本外观或文本颜色只会影响在任何地方绝对没有样式或属性的文本,包括系统定义的文本.如果你添加一个

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Medium Text" />
Run Code Online (Sandbox Code Playgroud)

即使没有android:textAppearance="?android:attr/textAppearanceMedium"Eclipse引入的行,它也会受到这个主题的影响,但按钮之类的东西永远不会.


ton*_*gil -1

主题和样式在您的环境中 sdk 实现的 theme.xml 和 styles.xml 文件中定义(不同的 android 版本或 sdk 级别有不同的文件)。

在计算机中搜索 theme.xml(例如,您可能会在 Windows 32 位计算机上的“program files/android”文件夹中找到它的多个实例)。

这篇文章解释了如何自定义这些属性。

您还可以通过修改TextView 标记属性在 xml 布局文件中设置显式大小属性:

<TextView  
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content"  
    android:text="15sp is the 'normal' size."  
    android:textSize="15sp"  
    />
Run Code Online (Sandbox Code Playgroud)

这篇文章解释了如何直接在 xml 布局文件中自定义 Android 字体(包括 fontType、fontColor、shadow、bold、italic)。