Java 在折叠工具栏布局中滚动时,如何将textview的内容设置为工具栏?

Java 在折叠工具栏布局中滚动时,如何将textview的内容设置为工具栏?,java,android,Java,Android,我在折叠工具栏布局中有一个活动,在嵌套滚动视图中有很多小部件,我用它们来查看产品的详细信息。。。我想在将活动向上滚动时,滑块下方的标题会转到工具栏并显示在工具栏上。。。我必须在.xml中添加更多属性还是在.java中编写代码 activity.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://sche

我在
折叠工具栏布局
中有一个活动,在
嵌套滚动视图
中有很多小部件,我用它们来查看产品的详细信息。。。我想在将活动向上滚动时,滑块下方的标题会转到工具栏并显示在工具栏上。。。我必须在.xml中添加更多属性还是在.java中编写代码

activity.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:background="@color/bg_main"
    tools:context=".DetailsActivity">


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

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleTextAppearance="@android:color/transparent"
            android:fitsSystemWindows="true">

            <com.daimajia.slider.library.SliderLayout
                android:id="@+id/sliderdetails"
                android:layout_width="match_parent"
                android:layout_height="300dp"
                />

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

            <ImageView
                android:id="@+id/img_cardtool"
                android:layout_width="25dp"
                android:layout_height="35dp"
                android:src="@drawable/ic_shop"
                android:layout_marginLeft="20dp"/>

            </android.support.v7.widget.Toolbar>
        </android.support.design.widget.CollapsingToolbarLayout>

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

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardElevation="0dp"
                android:layout_marginBottom="0dp"
                app:cardUseCompatPadding="true">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@color/bg_caption_details"
                    android:orientation="vertical">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:padding="6dp"
                        android:layout_gravity="left">

                        <ImageView
                            android:id="@+id/img_sharedetail"
                            android:layout_width="25dp"
                            android:layout_height="35dp"
                            android:src="@drawable/ic_shareb"
                            android:layout_marginLeft="5dp"
                            />

                        <ImageView
                            android:id="@+id/img_notificationdetail"
                            android:layout_width="25dp"
                            android:layout_height="35dp"
                            android:src="@drawable/ic_notification"
                            android:layout_marginLeft="20dp"
                            />

                        <ImageView
                            android:id="@+id/img_bookmarddetail"
                            android:layout_width="25dp"
                            android:layout_height="35dp"
                            android:src="@drawable/ic_fav"
                            android:layout_marginLeft="20dp"
                            />
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:padding="5dp">
                        <TextView
                            android:id="@+id/txtcaptiondetail"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:hint=" عنوان اصلی محصول"
                        android:textSize="16sp"
                        android:textStyle="bold"
                        android:textColor="@color/black"/>

                        <TextView
                            android:id="@+id/txtcaptiondescdetail"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="right"
                            android:hint=" عنوان دوم محصول"
                            android:textSize="14sp"
                            android:layout_marginTop="5dp"
                            android:textColor="@color/twotitle"/>
                    </LinearLayout>



                </LinearLayout>


            </android.support.v7.widget.CardView>

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="50dp">

                <android.support.v7.widget.CardView
                    android:id="@+id/cardView"
                    android:layout_width="150dp"
                    android:layout_height="35dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:foreground="?attr/selectableItemBackground"
                    android:background="@drawable/cardviewrounded"
                    android:clickable="true"
                    android:padding="6dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toEndOf="@+id/cardView2"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintVertical_bias="0.517">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        >

                        <ImageView
                            android:layout_width="20dp"
                            android:layout_height="20dp"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="5dp"
                            android:layout_toRightOf="@id/txtdesc"
                            android:src="@drawable/ic_contet" />

                        <TextView
                            android:id="@+id/txtdesc"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerHorizontal="true"
                            android:layout_centerVertical="true"
                            android:text="مشخصات"
                            android:textStyle="bold" />
                    </RelativeLayout>


                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:id="@+id/cardView2"
                    android:layout_width="150dp"
                    android:layout_height="35dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="8dp"
                    android:foreground="?attr/selectableItemBackground"
                    android:clickable="true"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@+id/cardView"
                    app:layout_constraintHorizontal_bias="0.5"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <ImageView
                            android:layout_width="20dp"
                            android:layout_height="20dp"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="5dp"
                            android:layout_toRightOf="@id/txtrespo"
                            android:src="@drawable/ic_response" />

                        <TextView
                            android:id="@+id/txtrespo"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerHorizontal="true"
                            android:layout_centerVertical="true"
                            android:layout_gravity="center"
                            android:text="نظرات کاربران"
                            android:textStyle="bold" />

                    </RelativeLayout>


                </android.support.v7.widget.CardView>

            </android.support.constraint.ConstraintLayout>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>


当前标题的行为是什么?@MohamedMohaidenah目前没有行为发生
应用程序:expandedTitleTextAppearance=“@android:color/transparent”
——您将标题设置为透明。您想要实现什么?@MohamedMohaidenah请按照您想要的
txtcaptiondetail
文本转到工具栏右侧查看此视频。。