首页 > 移动平台 > 详细

Android样式和主题

时间:2017-01-06 23:44:55      阅读:290      评论:0      收藏:0      [点我收藏+]

样式:style-->

 

主题:theme-->

 

  <style name="my_style">
        <item name="android:textSize">50sp</item>
        <item name="android:textColor">#ff0000</item>
        <item name= "android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>

    </style>

    <style name="my_theme">
        <item name="android:background">#ffff00</item>
        <item name="android:textColor">#ff0000</item>
        <item name= "android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>

    </style>
 <TextView
        android:text="aaa"
        style="@style/my_style"
     />
    <TextView
        android:text="bbb"
        style="@style/my_style"/>
    <TextView
        android:text="ccc"
        style="@style/my_style"/>
    <TextView
        android:text="ddd"
        style="@style/my_style"/>

 

 <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/my_theme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

 

 

共同点:定义方式相同

不同点:style作用范围小,一般作用于控件

theme作用范围大,一般用于activity或者application节点

style用的比较多

theme用的比较少

Android样式和主题

原文:http://www.cnblogs.com/doitbyyourself/p/6257478.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!