码迷,mamicode.com
首页 > 移动开发 > 详细

Android学习笔记之Theme主题的修改设置

时间:2015-01-16 16:43:49      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:android学习笔记之theme主题的

(1)布局文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <!-- 普通的样式使用方法 -->

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="31dp"
        android:text="@string/hello_world" />

    <!-- 自定义的样式使用方法 -->

    <TextView
        android:id="@+id/textView1"
        style="@style/CodeFont.RED.BIG"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/button1"
        style="@style/buttonStyle"
        android:layout_alignLeft="@+id/textView2"
        android:layout_centerVertical="true"
        android:text="Button"
        android:textColor="@color/textColor" />

</RelativeLayout>

(2)在values中新建xml文件

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="CodeFont" parent="@android:style/TextAppearance.Medium">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:typeface">monospace</item>
    </style>

    <style name="CodeFont.RED">
        <item name="android:textColor">#00FF00</item>
    </style>

    <style name="CodeFont.RED.BIG">
        <item name="android:textSize">20sp</item>
    </style>

    <style name="buttonStyle">
        <item name="android:textColor">#00FF00</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginTop">48dp</item>
        <item name="android:layout_marginLeft">148dp</item>
    </style>

    <color name="textColor">#ACBDEC</color>

    <!-- 自定义主题 需要在清单文件中修改Android默认的主题 -->
    <color name="custom_theme_color">#b0b0ff</color>

    <style name="CustomTheme" parent="android:Theme.Light">
        <item name="android:windowBackground">@color/custom_theme_color</item>
        <item name="android:colorBackground">@color/custom_theme_color</item>
    </style>

</resources>

(3)如果要修改Android默认的主题需要在清单文件中修改,下图圈出的位置就是需要修改的地方

技术分享

(4)其他问阿金都可以默认无需修改!


Android学习笔记之Theme主题的修改设置

标签:android学习笔记之theme主题的

原文地址:http://blog.csdn.net/xlgen157387/article/details/42778617

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!