Mak*_*iev 5 android themes textview
TextView我的应用程序中有很多s.它们有各种各样的字体大小,颜色等等.我需要应用它们android:shadowColor并android:shadowRadius让它们全部带有阴影.怎么做?
例如,我可以为TextView具有必要属性的s 制作样式
<style name="text_views">
<item name="android:shadowColor">@color/tv_shadow</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">0.7</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并将其应用于每个TextView.是否可以将阴影的属性包含在应用程序的主题中?
是的.
你需要做的是创建一个
<style name="Theme.RedPlanetTheme" parent="android:Theme">
<item name="android:shadowColor">@color/tv_shadow</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">0.7</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后在你的清单中你会这样做.
<application
android:debuggable="true"
android:icon="@drawable/icon"
android:label="Red Planet App"
android:theme="@style/Theme.RedPlanetTheme" >
Run Code Online (Sandbox Code Playgroud)
编辑
如果您只想申请textview,那么我们只需要更多地定制ThemeRedPlanet.
<style name="Theme.RedPlanetTheme" parent="android:Theme">
<item name="android:textAppearance">@style/MyRedTextAppearance</item>
</style>
<style name="MyRedTextAppearance" parent="@android:style/TextAppearance">
<item name="android:shadowColor">@color/tv_shadow</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">0.7</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我用它作为例子.Steve Pomeroy更直接地应用全球主题(设置曾经有点交易)
请将以下行添加到您的 textview 的属性中,它将解决您的问题。
style="@style/text_views"
| 归档时间: |
|
| 查看次数: |
17512 次 |
| 最近记录: |