首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Android应用程序中定义主题

在Android应用程序中定义主题
EN

Stack Overflow用户
提问于 2013-11-20 10:28:22
回答 2查看 2.1K关注 0票数 0

我试着在清单上加上

代码语言:javascript
复制
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

风格各异

代码语言:javascript
复制
<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>
</resources>

不管我做什么,我总是有黑色的动作吧,没有任何改变.我想应用全息光的主题..。

有什么建议吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-11-20 10:33:12

如果您想在整个应用程序中使用主题,请尝试如下:

代码语言:javascript
复制
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo.Light" >
票数 1
EN

Stack Overflow用户

发布于 2013-11-20 10:56:29

创建一个自定义主题。

首先,在值中添加如下所示的themes.xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.Light.NoTitleBar">
    <!-- Any customizations for your app running on pre-3.0 devices here -->
    </style>
</resources> 

然后,在res目录中创建一个名为“values v11”(Android 3.0+ )的目录,并放置如下所示的themes.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.Holo.Light">
    <!-- Any customizations for your app running on 3.0+ devices here -->
    </style>
</resources>

最后,在res目录中创建一个名为“values v14”(Android 4.0+)的目录,并创建一个themes.xml。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
    <!-- Any customizations for your app running on 4.0+ devices here -->
    </style>
</resources>

manifest.xml

代码语言:javascript
复制
<application
    ...
    android:theme="@style/MyAppTheme">

</application>

或创建自定义操作栏

actionbar_layout.xml

代码语言:javascript
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/ActionBarCompat" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="15dip"
        android:paddingTop="15dip"
        android:scaleType="center"
        android:textColor="#ffffff"
        android:textSize="20sp"
        android:textStyle="bold"
        android:text="NAME" />

</LinearLayout>

在你的布局文件里。main_activity.xml

代码语言:javascript
复制
   <include layout="@layout/actionbar_layout"/>

在值->contentes.xml中

代码语言:javascript
复制
<style name="ActionBarCompat">
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">50dp</item>
    <item name="android:orientation">horizontal</item>
    <item name="android:background">@drawable/actionbar_background</item>
</style>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20093342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档