• Android ----style


         Theme: 窗体级别,改变窗体样式

    style--<

         style:     窗体元素级别,改变指定控件或者Layout的样式。

    新建自定义的style和theme:
    1.在res/values 目录下新建名为style.xml的文件
    2.增加一个<resources>根节点。
    <resources>
     <style name="SpecialText" parent="@style/Text">
         <item name="android:textSize">18sp</item>
         <item name="android:textColor">#008</item>
     </style>
    </resources>

    3. 后面就可以使用SpecialText来应用style
    4.item用于定义名字属性,内部定义style的值(在Item当中的名字的属性可以是一个字符串,一个16进制数所表示的颜色或者是其他资源的引用。)
     
    5.parent中的内容表示自定义的style直接或者间接地继承Android的标准风格
    ***********使用方法***********
    <EditText id="@+id/text1"
        style="@style/SpecialText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Hello, World!" />
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    同style,theme依然在<style>中申明,也以同样的方式引用。
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
     <style name="CustomTheme">
        <item name="android:windowNoTitle">true</item>
        <item name="windowFrame">@drawable/screen_frame</item>
        <item name="windowBackground">@drawable/screen_background_white</item>
        <item name="panelForegroundColor">#FF000000</item>
        <item name="panelBackgroundColor">#FFFFFFFF</item>
        <item name="panelTextColor">?panelForegroundColor</item>
        <item name="panelTextSize">14</item>
        <item name="menuItemTextColor">?panelTextColor</item>
        <item name="menuItemTextSize">?panelTextSize</item>
     </style>
    </resources>
    **应用资源的位置
    @符号:表示应用的资源是前边定义过的(或者在前一个项目中或者在Android 框架中)。
    ?         表明了引用的资源的值在当前的主题当中定义过。通过引用在<item>里边定义的名字可以做到(panelTextColor 用的颜色和panelForegroundColor中定义的一样)。这中技巧只能用在XML资源当中。
     
    ****注意,Theme必须在Manifest中设置主题----下回再学
    学习资料来源:http://zyfromcq.iteye.com/blog/1401710
     
  • 相关阅读:
    django的命令, 配置,以及django使用mysql的流程
    vue中局部组件的使用
    Chapter14【Collection、泛型】
    泛型
    集合遍历的方式(迭代器和增强for)
    Collection集合
    集合
    数组
    包装类
    基本类型与字符串之间的转换
  • 原文地址:https://www.cnblogs.com/Cherrylalala/p/5948899.html
Copyright © 2020-2023  润新知