首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

style 运用

2012-09-24 
style 使用style[功能]style 就像 模板 即 一些属性的集合[使用]1. 定义一种 style 名字为 SpecialText 放

style 使用
style


[功能]
style 就像 模板 即 一些属性的集合


[使用]
1. 定义一种 style 名字为 SpecialText 放在 style.xml 中

<?xml version="1.0" encoding="utf-8"?><resources>    <style name="SpecialText" >        <item name="android:textSize">28sp</item>        <item name="android:textColor">@color/darkgreen</item>        <item name="android:gravity">center</item>        <item name="android:textStyle">bold|italic</item>        <item name="android:background">@drawable/dot</item>    </style></resources>


2. 使用
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    ><TextView  style="@style/SpecialText"    android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/hello"    /></LinearLayout>



3. 因为 SpecialText 有这行
<item name="android:textColor">@color/darkgreen</item>

故而需要 darkgreen 的定义:string.xml 的内容 如下
<?xml version="1.0" encoding="utf-8"?><resources>    <string name="hello">welcome to Android worlds!</string>    <string name="app_name">StylesUsage</string>    <color name="transparent_background">#0000FF</color>  <color name="translucent_background">#C2CE99</color>  <color name="blue">#0000FF</color>  <color name="white">#FFFFFF</color>  <color name="pink">#FFC8FF</color>  <color name="darkgreen">#008800</color></resources>


1 楼 codemania 2010-01-14   上些图就好了
否则不够直观 2 楼 gryphone 2010-01-14   codemania 写道上些图就好了
否则不够直观

没有图片啊 你说的是 dot.9.png 这个只是一个背景图片

热点排行