android - 在 style.xml 中设置底层 TextView 的样式

标签 android styles textview themes

如何通过样式设置 LinearLayout 的 TextView Child 的样式。像这样:

<style name="MyLinearayoutStyle" parent="MyParentStyle">
    <item name="android:background">@drawable/mybackground</item>
    <item name="android:padding>5dp</item>
    // Here i need to define my textview style
</style>


<style name="MyTextViewStyle> parent="AnotherParentStyle">
    <item name="android:textColor">@color/Black</item>
    <item name="android:textSize">15sp</item>
</style>

我尝试了 android:TextAppearance 和 android:textStyle,但这没有用。

最佳答案

更改主题定义((存储在 res/values/styles.xml 中):

<?xml version="1.0" encoding="utf-8"?> 
<resources>   
<style name="MyTheme" parent="android:Theme.Light">    
    <item name="android:textAppearance">@style/MyDefaultTextAppearance</item> 
</style>    
     <style name="MyDefaultTextAppearance" parent="@android:style/TextAppearance">    
     <item name="android:textSize">12sp</item>     
    <item name="android:textColor">#333</item>    
     <item name="android:textStyle">bold</item>   
    </style> 
    </resources>

关于android - 在 style.xml 中设置底层 TextView 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16603171/

相关文章:

android - 如何在 TextView 中选择文本时覆盖 "Copy"、 "Share"和 "Select All"选项

android - 我怎样才能拥有具有不同 TextView 和 Spinner 文本颜色的全局主题?

android - Badge TextView 文本未居中对齐

android - 阅读 Android 通知的全文?

android - ftpclient 不上传我的文件

android - YouTubeAndroidPlayerAPI 无法播放某些视频

c# - 如何继承样式并覆盖某些内容?

java - 尝试将 JUnit3 库添加到 Eclipse ADT 中的 Java 项目 - "the selected JUnit version is not available."

Javascript 参数偏好

asp.net - CSS 与不同浏览器的兼容性