没有设置Android主题

Ros*_*oss 19 android themes android-manifest android-styles

我有一个拒绝应用于活动的主题 - 没有应用任何样式.如果我没有为它提供layout_width/ layout_height属性<Button>也会收到运行时错误,表明Button该类没有被应用.

/res/values/themes.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme" parent="android:style/Theme.Black">
        <item name="android:windowNoTitle">true</item>
        <item name="android:buttonStyle">@style/Button</item>
        <item name="android:windowBackground">@color/page_background_light</item>
        <item name="android:textAppearance">@style/TextAppearance</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

/res/values/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="TextAppearance" parent="@android:style/TextAppearance">
        <item name="android:textSize">12sp</item>
        <item name="android:textColor">@color/darkblue</item>
    </style>
    <style name="Button" parent="@android:style/Widget.Button">
        <item name="android:layout_width">fill_parent</item> 
        <item name="android:layout_height">wrap_content</item>
        <!--<item name="android:textColor">#3C2F4F</item>
        <item name="android:textSize">20dip</item>-->
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

和相关的清单设置:

<application android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/Theme">
Run Code Online (Sandbox Code Playgroud)

我错过了哪个明显的错误?

Ana*_*a M 23

我一直在努力解决这个问题,并且认为我终于找到了可能存在的问题 - 也许它是一样的.

我在res\values文件夹中定义了自定义主题,但在values-v11values-v14文件夹中没有.我认为这使得在某些设备(特别是我正在测试的2个!)中,主题无法应用,因为它不存在.

我现在看到我的自定义主题中设置的属性(在应用程序级别应用)生效.


Ric*_*tte 0

只是出于好奇。尝试将您的主题重命名为其他名称,例如 FooBar。

在这里要说明显而易见的事情,但请确保您的按钮使用正确的样式。