将主题应用于应用程序

时间:2013-11-29 19:31:46

标签: android xml eclipse

我正在尝试将一个主题应用到我的整个Android应用程序,现在只改变应用程序中所有按钮的外观。目前我没有错误,应用程序将在我的虚拟机中启动(我正在使用eclipse)。我的问题是,尽管没有任何错误,主题不适用于应用程序。以下是我设置所有内容的方法:

RES /颜色/ custom_button.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" >
        <shape>
            <gradient
                android:startColor="@color/yellow1"
                android:endColor="@color/yellow2"
                android:angle="270" />
            <stroke
                android:width="3dp"
                android:color="@color/grey05" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>

    <item android:state_focused="true" >
        <shape>
            <gradient
                android:endColor="@color/orange4"
                android:startColor="@color/orange5"
                android:angle="270" />
            <stroke
                android:width="3dp"
                android:color="@color/grey05" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>

    <item>        
        <shape>
            <gradient
                android:endColor="@color/white1"
                android:startColor="@color/white2"
                android:angle="270" />
            <stroke
                android:width="3dp"
                android:color="@color/grey05" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>

</selector>

RES /值/ styles.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <resources >
      <style name="PurdueButtons" parent="android:style/Widget.Button">
          <item name="android:background">@color/custom_button</item>
      </style>
      <style name="PurdueTheme" parent="android:Theme.Holo">
          <item name="android:buttonStyle">@style/PurdueButtons</item>
      </style>
    </resources>

AndroidManifest的相对行:

android:theme="@style/PurdueTheme" >

我的所有颜色都在res / values / colors.xml中定义,我知道我已经正确设置了这个颜色。 Eclipse似乎没有问题找到所有内容,所以我很困惑为什么主题,主要是我对按钮所做的更改,没有被应用。

0 个答案:

没有答案