zoukankan      html  css  js  c++  java
  • Android:Style和Theme

    在Web开发中,Html负责内容,CSS负责表现。同样,在Android开发中,可以使用Theme、Style+UI组件的方式实现内容和形式的分离。

    Style是针对窗体元素级别的,改变指定控件或者Layout的样式

    Theme是针对窗体级别的,改变窗体样式;

    style演示

    定义一个styles,在res/values/目录下建立styles.xml

        <style name="mystyle" parent="AppBaseTheme">
            <item name="android:textSize">18sp</item>
            <item name="android:textColor">#ff0000</item>
        </style>

    <item name="属性">属性值</item>

    1、在布局文件中引用style

    <TextView
            style="@style/mystyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />

    2、在程序中设置style

     text.setTextAppearance(this, R.style.mystyle);

    效果:

     Theme演示

    1、在manifest当中设置主题

    theme的style可以定义在styles.xml中,也可以单独定义在自己新建的themes.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources xmlns:android="http://schemas.android.com/apk/res/android">
          <style name="myTheme" parent="AppBaseTheme">
            <item name="android:windowNoTitle">true</item>
      <item name="android:windowFullscreen">?android:windowNoTitle</item>
        </style>
    </resources>

    如果整个工程用一个主题就在application 标签中定义

    android:theme="@style/myTheme"

     其他属性:可以在sdk查看:..sdkplatformsandroid-7data esvalues hemes.xml

    android:windowBackground

    android:windowIsFloating

    android:windowIsTranslucent

    android:windowContentOverlay

    android:windowAnimationStyle

    android:backgroundDimEnabled

    相关:

    安卓自带的主题android:theme

  • 相关阅读:
    iOS开发快捷键
    通达信指标函数说明大全(2014)(转)
    windows下的wxWidgets环境配置
    Qt->数字格式化
    被称"硬盘杀手"的几个win7系统服务如何关闭(转)
    关闭系统索引(转)
    SSD固态硬盘优化(转)
    通达信的文件目录结构(转)
    Macdrive8破解版如何激活
    IOS6.0调用通讯录和之前的差别
  • 原文地址:https://www.cnblogs.com/tinyphp/p/3826098.html
Copyright © 2011-2022 走看看