android – 包含EditText的扩展工具栏

我第一次接触扩展/折叠工具栏.我在
this great tutorial之后得到了一些结果.

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

《android – 包含EditText的扩展工具栏》

对于几个EditTexts,以便我有类似的东西

《android – 包含EditText的扩展工具栏》

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

最佳答案 像这样创建你的布局

   <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>

以及您的活动/片段集中的内容

//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));
点赞