Ich schaffte es, die Statusleiste durchscheinend zu machen und jetzt habe ich ein Problem mit der Farbe. Aus irgendeinem Grund hat die Statusleiste die gleiche Farbe wie die Symbolleiste, wenn Sie nach oben streichen.Android, Symbolleiste und Statusleiste haben die gleiche Farbe
DetailsActivity.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/md_grey_200">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="260dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
app:layout_behavior="com.my.package.FlingBehavior">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="true"
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="76dp"
android:paddingTop="24dp"
app:layout_collapseMode="pin"
android:fitsSystemWindows="false"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RecyclerView
android:id="@+id/details_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
/>
</android.support.design.widget.CoordinatorLayout>
Arten-v21:
<style name="MyFinalTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- ...and here we setting appcompat’s color theme attrs -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/primary</item>
<item name="android:statusBarColor">@color/primary_dark</item>
</style>
Dies ist, was ich die Statusleiste durchscheinend machen verwenden:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
Ich habe versucht, die Farbe der Statusleiste in styles-v21 in primary_dark zu ändern, aber es hat nicht funktioniert. Weder hat diese:
w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
w.setStatusBarColor(Color.BLUE);
Colors.xml, wie gewünscht:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#00b386</color>
<color name="colorPrimaryDark">#008060</color>
<color name="colorAccent">#00e6ac</color>
</resources>
Was bin ich?
Welche Farbe möchten Sie ändern und in welcher Farbe? bitte angeben. poste deine colors.xml hier. –
Ich möchte die Farbe der Statusleiste in eine dunklere grüne Farbe ändern. Ich habe die colors.xml hinzugefügt – Alec