Ich habe eine AppCompatActivity mit transparenter Symbolleiste. Das Problem ist, dass auf Geräten unter API 21 der Titel und der Pfeil (nach oben) der Symbolleiste transparent ist. Ich weiß, dass es da ist, weil das Klicken auf den unsichtbaren Pfeil mich zu der letzten Aktivität zurückbringt. Geräte mit API 21 und höher zeigen einen weißen Titel und einen weißen Zurück-Pfeil.Symbolleistentitel ist transparent
Mein styles.xml (based on this answer)
<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>
<!-- from https://stackoverflow.com/questions/29907615/android-transparent-status-bar-and-actionbar -->
<style name="AppTheme.Transparent" parent="AppTheme">
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBarOverlay">true</item>
<item name="colorPrimary">@android:color/transparent</item>
</style>
und meine styles.xml (v21)
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorAccent</item>
<item name="android:windowContentTransitions">true</item>
</style>
<!-- from https://stackoverflow.com/questions/29907615/android-transparent-status-bar-and-actionbar -->
<style name="AppTheme.Transparent" parent="AppTheme">
<item name="colorPrimary">@android:color/transparent</item>
</style>
Die Symbolleiste
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:elevation="4dp"
android:fitsSystemWindows="true"
app:theme="@style/ThemeOverlay.AppCompat.Dark"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
Ich habe auch versucht app:titleTextColor="@android:color/white"
Hinzufügen und Verpackung der Symbolleiste in einem AppBarLayout
. Ohne Erfolg.
----- ------ EDIT
Der wichtige Teil des AppCompatActivity
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
...
public class DetailsActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_view);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
String title = ...
getSupportActionBar().setTitle(title);
...
}
...
}
suchen Danke für die Antwort. Leider hat es nicht geholfen. Ich habe bereits die 'android.support.v7.widget.Toolbar' importiert. Ich habe den wichtigen Teil des Codes der Avtivity dem Hauptpost hinzugefügt. – Alexander
in Ihrem App-Design in style.xml, hinzufügen: ' false' –
Keine Änderung. Wahrscheinlich weil mein Stil bereits von '* .NoActionBar' abgeleitet ist. – Alexander