Android 展开包含编辑文本的工具栏

Android 展开包含编辑文本的工具栏,android,android-toolbar,Android,Android Toolbar,我第一次接触到展开/折叠工具栏。下面我有一些结果 现在,我想(如果可能的话)替换静态标题(参见下面的标题“Anthoriro”) 对于两个EditTexts,我有类似的东西 在这种情况下,折叠工具栏时显示的文本将是标题“项目优先级”。创建如下布局 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android

我第一次接触到展开/折叠工具栏。下面我有一些结果

现在,我想(如果可能的话)替换静态标题(参见下面的标题“Anthoriro”)

对于两个
EditText
s,我有类似的东西


在这种情况下,折叠工具栏时显示的文本将是标题“项目优先级”。

创建如下布局

   <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/htab_maincontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">

            <android.support.design.widget.AppBarLayout
                android:id="@+id/htab_appbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/htab_collapse_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:fitsSystemWindows="true"
                    app:contentScrim="?attr/colorPrimary"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed">

                    <RelativeLayout
                        android:id="@+id/htab_header"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:fitsSystemWindows="true"
                        app:layout_collapseMode="parallax"
                        >

                        <EditText
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:inputType="text"
                            android:ems="10"
                            android:id="@+id/editText2"
                            android:hint="Title"
                            android:text="Project"
                            android:layout_centerVertical="true"
                            android:layout_centerHorizontal="true"/>

                        <EditText
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Name"
                            android:ems="10"
                            android:id="@+id/editText3"
                            android:layout_below="@+id/editText2"
                            android:layout_alignLeft="@+id/editText2"
                            android:layout_alignStart="@+id/editText2"
                            android:layout_marginTop="28dp"
                            android:inputType="text"/>
                    </RelativeLayout>

                    <android.support.v7.widget.Toolbar
                        android:id="@+id/mToolbar"
                        android:layout_width="match_parent"
                        android:layout_height="56dp"
                        android:gravity="top"
                        android:minHeight="?attr/actionBarSize"
                        app:layout_collapseMode="pin"
                        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                        />


                </android.support.design.widget.CollapsingToolbarLayout>
            </android.support.design.widget.AppBarLayout>


       <--Swap this with your scrollable view -->

            <android.support.v4.view.ViewPager
                android:id="@+id/mViewPager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
        </android.support.design.widget.CoordinatorLayout>

我最后一次尝试类似于这种方法,但它并没有像我期望的那样工作。我想对于我想要的东西没有一个好的解决方案,因为我还没有看到任何类似的应用程序。你可以在textinput上附加文本更改侦听器,并设置ContextChanged标题,但我认为这在ui方面真的很糟糕
//Dont forget to find your CoolapsingLayout first :)

//set The custom text
mCollapisngToolbar.setTitle("TEXTTTs");

//Set the color of collapsed toolbar text
mCollapisngToolbar.setCollapsedTitleTextColor(ContextCompat.getColor(this, R.color.White));

//This will set Expanded text to transparent so it wount overlap the content of the toolbar          
mCollapisngToolbar.setExpandedTitleColor(ContextCompat.getColor(this, R.color.Transparent));