Ändern Sie die Farbe von meinem CollapsingToolbarLayout
Ich versuche zu tun, eine CollapsingToolbar animation basiert auf Material-Design-Regeln. Alles funktioniert gut, aber eine Sache, die bricht mein Geist. Ich bin versucht zu ändern die Farbe meiner Zusammengebrochen tool-Leiste beim scrollen meine recycler Blick, aber die transparente Farbe, die ich bekomme ist immer die gleiche...
Hier mein xml-code:
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="256dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
android:background="@color/gps_friends_green_main"
app:contentScrim="@color/gps_friends_green_main"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/imgHeader"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolBarDetalleContacto"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/MyNavigationDrawerTheme"
app:layout_collapseMode="pin">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Und hier ist mein Java-code
int mutedColor = R.color.gps_friends_green_main;
Palette.generateAsync(bitmap,
new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch vibrant =
palette.getVibrantSwatch();
if (vibrant != null) {
//If we have a vibrant color
//update the title TextView
collapseToolbar.setBackgroundColor(mutedColor);
// mutedColor = palette.getMutedColor(R.attr.colorPrimary);
collapseToolbar.setStatusBarScrimColor(palette.getDarkMutedColor(R.color.gps_friends_green_main));
collapseToolbar.setContentScrimColor(palette.getMutedColor(R.color.gps_friends_green_main));
}
}
});
Wo gps_friend_main_color ist <color name="gps_friends_green_main">#1abc9c</color>
Dies ist das Ergebnis meiner zusammengebrochen toolbar:
Möchte ich dies ändern, dunkelblaue Farbe, aber ich finde nicht den Weg das zu tun. Ich bin ein bisschen verzweifelt, aber hoffe, die Antwort zu finden hier.
Danke.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ihren code, um die Farbe zu ändern, ist richtig.
Sie haben nur entfernen Sie die
app:contentScrim="@color/gps_friends_green_main"
in Ihrem "android.Unterstützung.design.- widget.CollapsingToolbarLayout", und es sollte funktionieren.
Verwenden Sie diese in Ihrem AppBarLayout:
android:background="@android:color/transparent" //verwenden Sie eine beliebige Farbe hier