2014-12-02 17 views
5

Ich bin neu in Android Material Design Concept. Ich habe ein neues Projekt erstellt und Material mit AppCompat-Unterstützung für Pre-Lollipop-Versionen hinzugefügt, aber mein Problem ist, in Lollipop zeigt es die ActionBar aka Toolbar, aber wenn ich das gleiche in Pre-Lollipop ausführen zeigt es nicht die ActionBar.Android Material Design AppCompat

Muss ich die Symbolleistensteuerung überall in meinem Layout verwenden, unabhängig von der API-Version?

Edited:

<!-- Base application theme for prelollipop --> 
<style name="AppTheme" parent="Theme.AppCompat.Light"> 
    <item name="colorPrimary">@color/primary_dark</item> 
    <item name="colorPrimaryDark">@color/primary_dark</item> 
</style> 

<!-- Material theme for lollipop--> 
<style name="AppTheme" parent="android:Theme.Material.Light"> 
    <item name="android:colorPrimary">@color/primary</item> 
    <item name="android:colorPrimaryDark">@color/primary_dark</item> 
</style> 
+2

https://github.com/antoniolg/MaterialEverywhere schauen Sie sich das an. –

+0

Veröffentlichen Sie Ihr Layout, Ihren Stil und Ihren Code –

+0

@Gabriele Mariotti Keine große Sache. Es war nur ein Standardprojekt, um mit dem Thema Material herumzuspielen, als eine Überprüfung, bevor ich es in meine eigentliche App implementiere. Frage ist für Sie bearbeitet – Kirk

Antwort

-1

versuchen diese

<style name="FamilyDashboardTheme" parent="Theme.AppCompat.Light.NoActionBar"> 

    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/familycolor</item> 
    <item name="colorPrimaryDark">@color/familydarkcolor</item> 
    <item name="colorAccent">@color/familycolor</item> 
    <item name="android:textColorPrimary">@android:color/white</item> 
    <item name="android:windowBackground">@android:color/white</item> 
</style> 
1

Ihre Aktivität ActionBarActivity verlängern müssen. Sie können den speziellen V21-Stil ablegen.

Wenn Ihr Stil Theme.AppCompat oder Theme.AppCompat.Light erweitert, sollte automatisch eine Standardaktionsleiste angezeigt werden. Wenn der Stil ...NoActionBar erweitert, müssen Sie es im Layout wie in reinem LOLLIPOP angeben. Die zweite Option gibt Ihnen eine bessere Kontrolle über das Toolbar Theming.

+0

ActionBarActivity ist veraltet. Verwenden Sie stattdessen {@link android.support.v7.app.AppCompatActivity}. –