android - CollapsableToolbarLayout with custom Toolbar height -


i'm creating layout using coordinatorlayout holding appbarlayout collapsabletoolbarlayout , toolbar. below app bar recyclerview.

when scrolling in recyclerview, toolbar should collapse, similar cheesesquare demo app. difference demo 1) want toolbar (including title) statically @ top (so i've set app:titleenabled on ctl), , 2) don't want collapse app bar only showing single line toolbar since have text views etc below toolbar app bar should never collapse beyond. using custom behavior control these text views during collapsing, , works fine.

problem is, don't seem grasp how best set anchor point @ collapsing end. know app bar collapse until snaps to height of toolbar. need either put custom views inside toolbar, hence increasing height of toolbar itself, or somehow instruct ctl anchor custom view instead. however, whenever change height of toolbar, title text gets strangely aligned , haven't found way of keeping aligned set of reasonable attributes.

question is, should playing height of toolbar @ all, or there way of getting ctl stop collapsing @ other anchor point bottom of toolbar?

or should indeed modify height of toolbar , place own layout in includes title text, , manually make sure align vertically toolbar icons etc? best i've managed far place linearlayout containing textview inside toolbar, hard-coded layout_margintop="14dp", might have compat issues. seems strange wouldn't possible increase height of toolbar while still maintaining default title text position.

or should not use ctl @ instead create custom behavior parts collapses app bar during initial recyclerview scroll events?

i've searched similar questions obviously, , closest i've found this question not address problem title text getting messed up.

my current layout, including ugly hard-coded manual title textview inside toolbar:

<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:id="@+id/appbar"         android:layout_width="match_parent"         android:layout_height="180dp"         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"             app:layout_scrollflags="scroll|exituntilcollapsed"             app:titleenabled="false"             app:contentscrim="?attr/colorprimary">              <android.support.v7.widget.toolbar                 android:id="@+id/toolbar"                 android:layout_width="match_parent"                 android:layout_height="110dp"                 app:popuptheme="@style/themeoverlay.appcompat.light"                 app:layout_collapsemode="pin">                  <linearlayout                     android:layout_width="match_parent"                     android:layout_height="match_parent"                     android:layout_margintop="14dp">                      <textview                         style="@style/textappearance.appcompat.widget.actionbar.title"                         android:layout_width="wrap_content"                         android:layout_height="wrap_content" android:text="title"/ >                  </linearlayout>             </android.support.v7.widget.toolbar>          </android.support.design.widget.collapsingtoolbarlayout>      </android.support.design.widget.appbarlayout>      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_margintop="80dp"         android:elevation="10dp"         android:gravity="center"         android:orientation="horizontal"         app:layout_anchor="@id/toolbar"         app:layout_behavior="my behavior class">          <!-- custom views shown in app bar, animated through custom behavior -->      </linearlayout>      <android.support.v7.widget.recyclerview android:id="@+id/list"         android:layout_width="match_parent"         android:layout_height="match_parent"         app:layout_behavior="@string/appbar_scrolling_view_behavior"         />  </android.support.design.widget.coordinatorlayout> 


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -