android - How to have a textview transition to the title in a collapsing toolbar? -
i have collapsingtoolbarlayout
contains textview
, ratingbar
under textview
. possible have textview
somehow transition title?
i want "title" transition toolbar collapses. there button, how ensure textview transitions proper place (to right side of button)?
edit: here xml
<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:layout_width="match_parent" android:layout_height="@dimen/detail_view_app_bar_height" android:fitssystemwindows="true" android:theme="@style/themeoverlay.appcompat.dark.actionbar"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" app:contentscrim="?attr/colorprimary" app:expandedtitletextappearance="@style/collapsingtoolbarlayoutexpandedtextstyle" app:layout_scrollflags="scroll|exituntilcollapsed"> <imageview android:id="@+id/image" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" android:scaletype="centercrop" app:layout_collapsemode="parallax"/> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginleft="@dimen/double_margin" android:gravity="center_vertical" android:orientation="vertical" app:layout_collapsemode="parallax"> <textview android:id="@+id/title" fontpath="fonts/opensans-bold.ttf" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="title" android:textcolor="@android:color/white" android:textsize="@dimen/large_text"/> <ratingbar android:id="@+id/rating_bar" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </linearlayout> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout> </android.support.design.widget.coordinatorlayout>
the solution is: don't use textview
.
you can position expanded title wherever want using these collapsingtoolbarlayout
attributes:
app:expandedtitlegravity default bottom|left -or- bottom|start app:expandedtitlemargin app:expandedtitlemarginbottom app:expandedtitlemarginstart app:expandedtitlemarginend
i assuming using noactionbar
theme, why started off textview
title.
so here layout, fixed use collapsingtoolbarlayout
title:
<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.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="@dimen/detail_view_app_bar_height" android:fitssystemwindows="true" android:theme="@style/themeoverlay.appcompat.dark.actionbar"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" app:contentscrim="?attr/colorprimary" app:expandedtitletextappearance="@style/collapsingtoolbarlayoutexpandedtextstyle" app:expandedtitlemarginbottom="64dp" app:expandedtitlemarginstart="16dp" app:layout_scrollflags="scroll|exituntilcollapsed"> <!-- set expandedtitlemarginbottom value positions expanded title above rating bar --> <imageview android:id="@+id/image" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" android:scaletype="centercrop" app:layout_collapsemode="parallax" /> <ratingbar android:id="@+id/rating_bar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginleft="16dp" 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.design.widget.coordinatorlayout>
then in code, set title on collapsingtoolbarlayout
:
collapsingtoolbarlayout collapsingtoolbar = (collapsingtoolbarlayout) findviewbyid(r.id.collapsing_toolbar_layout); collapsingtoolbar.settitle("title");
Comments
Post a Comment