2013-01-15 18 views
6

MinSDKVersion = 7 TargetSDKVersion = 17Android: Jak korzystać z różnych motywów dla różnych wersji Androida?

Jeśli użytkownik posiada SDKVersion 11 lub wyższy Chciałbym ustawić motyw do Theme.Holo.Light. To nie działa dla mnie tutaj. Kiedy uruchomić aplikację na urządzeniu 3.1 to po prostu wykorzystuje Theme.Light:

enter image description here

samo kiedy uruchomić tę aplikację na urządzeniu z wersji niższej niż 3.1

My Folderstructure:

enter image description here

Oczywisty:

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/MyTheme" > 

Wartości-v11:

<resources> 

<!-- 
    Base application theme, dependent on API level. This theme is replaced 
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
--> 
<style name="AppBaseTheme" parent="@android:style/Theme.Light"> 
    <!-- 
     Theme customizations available in newer API levels can go in 
     res/values-vXX/styles.xml, while customizations related to 
     backward-compatibility can go here. 
    --> 
</style> 

<!-- Application theme. --> 
<style name="AppTheme" parent="@android:style/Theme.Light"> 
    <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
</style> 


<style name="MyTheme" parent="@android:style/Theme.Holo.Light"> 
    <!-- Any customizations for your app running on devices with Theme.Holo here --> 
</style> 

innymi wartościami foldery:

<resources> 

<!-- 
    Base application theme, dependent on API level. This theme is replaced 
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
--> 
<style name="AppBaseTheme" parent="@android:style/Theme.Light"> 
    <!-- 
     Theme customizations available in newer API levels can go in 
     res/values-vXX/styles.xml, while customizations related to 
     backward-compatibility can go here. 
    --> 
</style> 

<!-- Application theme. --> 
<style name="AppTheme" parent="@android:style/Theme.Light"> 
    <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
</style> 

    <style name="MyTheme" parent="@android:style/Theme.Light"> 
    <!-- Any customizations for your app running on devices with Theme.Holo here --> 
</style> 

Jak mogę wykorzystać to poprawnie?

poważaniem Marco Seiz

Odpowiedz

6

Dlaczego masz motywu dwukrotnie w pliku styles.xml?

<style name="AppTheme" parent="@android:style/Theme.Light"> 
    <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
</style> 


<style name="MyTheme" parent="@android:style/Theme.Holo.Light"> 
    <!-- Any customizations for your app running on devices with Theme.Holo here --> 
</style> 

Usunięcie jednego nie potrzeba (w tym przypadku motyw Theme.Light):

Wartości-V11:

<style name="MyTheme" parent="@android:style/Theme.Holo.Light"> 
    <!-- Any customizations for your app running on devices with Theme.Holo here --> 
</style> 

wartości:

<style name="MyTheme" parent="@android:style/Theme.Light"> 
    <!-- Any customizations for your app running on devices with Theme.Holo here --> 
</style> 

+0

zrobiłem to, ale nadal wykazały stary temat i nie Tematem holo na moim Androidzie 4.1 i 3.1 urządzenia –

+0

Czy usunąć powielania? – Ahmad

+0

Tak, zrobiłem. Zrozumiałem błąd. Musiałem stworzyć dwa foldery dla jednego języka. Dla języka niemieckiego: values-de AND values-de-v11 i to samo dla języka angielskiego ... Działa teraz :) Dzięki za pomoc i wskazówki! –

2

Umieść Rozwiązanie dostarczone przez @Ahmad w nowych plikach nazywa themes.xml na wspomnianych katalogach on :-)

Jeśli użyjesz wielojęzyczne i multithemes, można przyjrzeć się podobnym pytaniem ja zrobiłem kilka minut przed ..., ale odpowiedział:

Multilanguage and multitheme at same time

Powiązane problemy