Android的样式API 10和API 11 [英] Android Styles For API 10 and API 11

查看:192
本文介绍了Android的样式API 10和API 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一些事情,我觉得在概念上非常简单。我想我的应用程序一路支持回API 10(姜饼)。为了使这个好看,我需要对我的按钮上的文本的颜色略有变化在设备运行API 10.因此,我想创建两种风格:其中一个将被使用时,该设备正在使用API 10(我想要的按钮的文本颜色为黑色在这种情况下),并且当设备正在使用的API 11或另一个之上(文本颜色将是在此情况下,默认的ICS灰色)。要做到这一点,我使用的是价值观和价值观-V11夹。里面的值文件夹是用下面的code进行的themes.xml文件:

I am trying to do something that I feel to be very simple in concept. I would like my app to be supported all the way back to API 10 (Gingerbread). To make this look good, I need to make a slight change to the color of the text on my buttons when the device is running API 10. Thus, I want to create two styles: one of which will be used when the device is using API 10 (I want the text color of the buttons to be black in this case), and another when the device is using API 11 or above (the text color will be the default ICS grayish in this case). To do this, I am using a values and a values-v11 folder. Inside the values folder is a themes.xml file with the following code:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="buttonColorStyle">
        <item name="android:textAppearanceButton">@style/buttonTextColor</item>
    </style>

    <style name="buttonTextColor">
       <item name="android:textColor">#FFFFFF</item>
    </style>
</resources> 

然而,当我与我的目标SDK应用程序集加载至10日,按钮的文本颜色是从默认灰色不变。此外,这里是code为我的按钮中的一个应该使用这种方式:

However, when I load up my app with target SDK set to 10, the text color of the buttons is unchanged from the default grayish. Also, here is the code for one of my buttons which should use this style:

<Button
        style="@style/buttonColorStyle"
        android:id="@+id/thirdSectionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:onClick="sectionButtonClicked"
        android:text="Section 3"
        android:textSize="11.5sp" />

任何人有什么想法?

Anyone have any ideas?

推荐答案

为什么不设置相同款式不错所有版本?

why not setting the same nice style for all versions?

您可以使用这个库(在Android开发者还建议博客的这里)。

you can use this library (also suggested at the android developers blog here) for making all of the devices use the holo theme.

另外,刚刚离开现在的风格,这样用户会觉得更家与他目前的操作系统风格(因为它可以公司之间的变化)。

alternatively , just leave the current style , so that the user will feel more "at home" with his current style of the OS (since it can change between companies) .

这篇关于Android的样式API 10和API 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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