zoukankan      html  css  js  c++  java
  • Android的样式与主题

    在开发过程中,Style和Theme是不可缺少的一部分,本文主要讲述了如何创建样式和主题。

    Style:定义控件属性

    1. 创建样式步骤如下:

    • 在res/Values目录下新建一个Android XML File,名为styles.xml。文件名可以自定义
    • 定义一个字体大小为20dp,颜色为#FF0000的样式,在xml文件中写入如下代码
      <?xml version="1.0" encoding="UTF-8"?>
      <resources>

          <style name="firstSytle">
              <item name="android:textSize">20dp</item>
              <item name="android:textColor">#FF0000</item>
          </style>

      </resources>
    • 引用TextView控件
      <TextView style="@style/firstSytle">第一个样式</TextView>
    • 这样Style就创建成功了,在R文件中会生成标识。

     2.重用父样式,只需要在Style标签中加入parent 属性,让它的值为父样式的name

      <style name="secondStyle" parent="firstSytle">
            <item name="android:background">#00FF00</item>
        </style>

    或者用“.”来标识

     <style name="firstSytle.secondStyle" >
            <item name="android:background">#00FF00</item>
        </style>

    Theme:可以理解为用来定一个Activity或者一个应用程序的样式

    1.同样在Theme文件中创建Style

       <style name="firstTheme">
            <item name=android:textColor>#FF0000</item>
        
    </style>

    2. 主题的调用,如果使用在整个系统中,可以在AndroidManifest.xml的Application中指定

     android:theme="firstThemt",如果使用在某个Activity中,就放在Activity中。
  • 相关阅读:
    圣诞树
    删除临时表并且插入数据
    sql语句中查询用in的时候,按in的顺序来输出
    xmlhelper and excelhelper
    几个小知识点。
    根据页面上记录数和页面大小获取总页数
    SQL语句的疑问
    katie melua the closest thing to crazy
    something about table
    little things
  • 原文地址:https://www.cnblogs.com/Enno/p/2366929.html
Copyright © 2011-2022 走看看