【问题标题】:Activity won't recognize custom themeActivity 无法识别自定义主题
【发布时间】:2015-12-15 05:00:29
【问题描述】:

我尝试了 3 个不同的地方(清单、onCreate 和 XML)来为单个活动获取自定义主题,但它不起作用?它在 genymotion 和设备上也失败了。清单代码

<activity
        android:name=".HomepageActivity"
        android:label="@string/title_activity_homepage"
        android:theme="@style/SecondTheme">
</activity>

这是 onCreate

super.onCreate(savedInstanceState);
    setTheme(R.style.SecondTheme);
    setContentView(R.layout.activity_homepage);

这是 XML

xmlns:app="http://schemas.android.com/apk/res-auto"
android:theme="@style/SecondTheme"
android:layout_width="match_parent"
android:layout_height="match_parent"

这是样式 v21/styles.xml

<style name="SecondTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here -->

    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColorPrimary">@color/colorTextPrimary</item>
    <item name="android:textColorSecondary">@color/colorTextSecondary</item>

</style>

有人看到我做错了吗???

【问题讨论】:

    标签: android android-activity android-manifest android-5.0-lollipop android-xml


    【解决方案1】:

    根据您的代码,主题仅适用于 v21。将主题文件移动到 value 文件夹

    【讨论】:

    • 在将其移至 v21 之前尝试过,但没有区别,最初我使用 values/styles.xml
    • 我说从 v21 移动到 value 文件夹。
    猜你喜欢
    • 2020-06-15
    • 2015-03-23
    • 1970-01-01
    • 2019-08-27
    • 2016-01-30
    • 2012-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多