Pracuję z CollapsingToolbarLayout z nowej biblioteki wsparcia projektowania Androida.Android CollapsingToolbarLayout Tytuł background
Ustawiłem jego tytuł i działa dobrze, jedynym problemem, jaki mam nadal, jest to, że podczas przewijania tekst jest tracony, w zależności od obrazu w tle.
Co chciałbym zrobić, jest ustawione tło dla tytułu CollapseingToolbarLayout, ale nie znalazłem sposób to zrobić.
Czy jest mimo to, aby to osiągnąć?
Dzięki!
Układ:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<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">
<ImageView
android:id="@+id/ivBigImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_gravity="fill_vertical"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="24dp">
<android.support.v7.widget.CardView
android:id="@+id/cvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<LinearLayout
style="@style/Image.Info.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/description"
android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
<TextView
android:id="@+id/tvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Konfigurowanie tytuł CollapsingToolbarLayout aktywności:
CollapsingToolbarLayout collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle("Some title here");
Edit:
Tutaj można zobaczyć sekwencję obrazów kiedy zwinąć pasek narzędzi. Możesz zobaczyć, jak tekst tytułu jest nieczytelny. Problem polega na tym, że nie mam kontroli nad obrazami, które pokazuję, więc dla niektórych obrazów wygląda to dobrze, ale dla innych, jak ten przykład, nie wygląda dobrze i nie jest czytelny. Miałem na myśli dodanie tła do tekstu, więc zawsze jest ten sam kolor z tyłu tekstu i jest on zawsze czytelny.
Nie trzeba dodać kod, to jest tylko prosty CoordinatorToolbarLayout. Nic nadzwyczajnego tutaj - ale i tak to będzie. –
@Rared Burrows Tutaj nie ma potrzeby wprowadzania kodu, to podstawowa funkcjonalność. Poza tym, dlaczego zawracasz sobie głowę komentowaniem? Jeśli nie chcesz pomóc, zamknij kartę i przejdź dalej swoim życiem. –
Witam @roy_lennon Miałem do czynienia z dokładnie tym samym problemem, co Ty, ale zastosowałem opisane poniżej rozwiązanie bez żadnych konsekwencji. Nadal widzę widok w zwiniętymbardzienakładka dokładnie tak, jak poprzednio (i dokładnie tak, jak to opisałeś w swoim pytaniu) czy mógłbyś mi pomóc? – neteot