1

Как правильно сделать, чтоб toolbar никогда не скролился, а поле title, уходило за него и останавливалось. введите сюда описание изображения

Чтоб было так:

введите сюда описание изображения

введите сюда описание изображения

Layout Разметка:

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".controllers_drawer.EventActivity">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppBar">

            <net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout
                android:id="@+id/event_collapsing_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
                app:contentScrim="@color/dark38"
                app:maxLines="3">

                <android.support.v4.view.ViewPager
                    android:layout_width="match_parent"
                    android:layout_height="360dp"
                    android:id="@+id/slider_viewpager"
                    android:transitionName="event_image"
                    android:scaleY="2"
                    android:scaleX="2"
                    android:fitsSystemWindows="true"
                    app:layout_collapseMode="parallax"
                    android:visibility="visible"/>

               <android.support.v7.widget.Toolbar
                   android:id="@+id/toolbar"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   app:layout_collapseMode="pin"/>

            </net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="90dp"
                android:background="@color/background_title_event"
                android:paddingTop="8dp"
                android:paddingBottom="8dp"
                android:paddingLeft="42dp"
                android:paddingRight="42dp"
                app:layout_scrollFlags="scroll|enterAlways">

                <TextView
                    android:id="@+id/event_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Event Long Long Long Logn Title"
                    android:textAllCaps="true"
                    android:textSize="32sp"
                    android:maxLines="2"
                    android:textColor="@android:color/white"
                    android:gravity="center"
                    android:layout_gravity="center"/>
            </LinearLayout>

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


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


                          ....


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

        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:id="@+id/fab"
            app:fabSize="normal"
            android:layout_margin="16dp"
            app:srcCompat="@drawable/ic_edt_white"
            />


    </android.support.design.widget.CoordinatorLayout>
    <include layout="@layout/drawer_layout"/>
</android.support.v4.widget.DrawerLayout>

2 ответа 2

0

Сделайте отдельную view в Collapsingtoolbarlayout для отображения title.

1
  • он оказывается на верху и если поставить gravity_layout - bottom, то вообще не скролится. Можно по подробней) 21 ноя 2016 в 8:53
0

Попробуйте так

ActionBar actionBar = getSupportActionBar();
            if (actionBar != null) {
                actionBar.setDisplayHomeAsUpEnabled(true);
                actionBar.setTitle("Ваш TITLE");
            }

и плюс в CollapsingToolbarLayout

        app:expandedTitleGravity="center"
        app:expandedTitleMarginTop="100dp"

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.