0

J'ai un modèle de tiroir de navigation. J'ai modifié la barre d'action pour ne pas voir le titre. Et je sais comment changer les couleurs, mais je ne sais pas comment cet effet:Android Studio - Barre d'action transparente - Tiroir de navigation

enter image description here

Ceci est mon état actuel:

enter image description here

Ceci est mon styles.xml (ce teme j'utilise):

<resources> 

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 
<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

Répondre

0

Vous pouvez utiliser Toolbar avec un arrière-plan transparent.

activity_main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:id="@+id/your_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#4BAE4F" 
     android:orientation="vertical"> 

     <!--Place your content here--> 

    </LinearLayout> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@android:color/transparent" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    </android.support.v7.widget.Toolbar> 

</RelativeLayout> 

MainActivity.java:

public class MainActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); 
    } 
} 

styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 

    </style> 

A partir de l'API 19, vous pouvez définir le paramètre <item name="android:windowTranslucentStatus">true</item> dans votre styles.xml pour rendre également la barre d'état transparente.

+0

J'ai essayé, mais l'application continue de se bloquer. Existe-t-il un autre moyen d'obtenir cet effet ou dois-je redémarrer l'application entière? – Ivan

+0

vérifier la sortie de logcat pour connaître la raison de l'accident. Assurez-vous également de définir le parent de votre AppTheme sur 'Theme.AppCompat.Light.NoActionBar'. – dzikovskyy