0

我尝试了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> 

任何人都明白我的做错了吗?

回答

0

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

+0

尝试将它移动到v21之前,但没有任何区别,最初我使用的值/ styles.xml – JC23

+0

我说从v21移动到值文件夹。 – anoopg87