zoukankan      html  css  js  c++  java
  • 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
     
  • 相关阅读:
    最近几个月的感想
    Fortran 入门——C#调用Fortran DLL
    Fortran 入门——函数调用
    JQueryAjax初体验和一点感想
    【HDU】1796 How many integers can you find
    【SGU】476 Coach's Trouble
    【HDU】2204 Eddy's爱好
    【POJ】1091 跳蚤
    【URAL】1091 Tmutarakan Exams
    【ZOJ】2836 Number Puzzle
  • 原文地址:https://www.cnblogs.com/Cherrylalala/p/5948899.html
Copyright © 2011-2022 走看看