如何更改主题的Andr​​oid应用程序? [英] How do I change the theme on an Android application?

查看:219
本文介绍了如何更改主题的Andr​​oid应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Android应用程序,我想改变应用程序的颜色和主题。我怎样才能做到这一点?

I'm developing an Android application and I want to change the color and theme of the application. How can I do this?

推荐答案

开发指南介绍如何应用主题和风格。

本:

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="#00FF00"
    android:typeface="monospace"
    android:text="@string/hello" />

成为本:

<TextView
    style="@style/CodeFont"
    android:text="@string/hello" />

通过定义XML主题文件:

By defining an xml theme file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <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:textColor">#00FF00</item>
        <item name="android:typeface">monospace</item>
    </style>
</resources>

您也可以将样式应用于应用程序的所有活动:

You can also apply styles to all activities of an application:

<application android:theme="@style/CustomTheme">

或者只是一个活动:

Or just one activity:

<activity android:theme="@android:style/Theme.Dialog">

这篇关于如何更改主题的Andr​​oid应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆