(设计支持库)CollapsingToolbarLayout如何使它始终滚动? [英] (Design Support Library) CollapsingToolbarLayout How to make it scroll always?

查看:363
本文介绍了(设计支持库)CollapsingToolbarLayout如何使它始终滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个CollapsingToolbarLayout总是滚动即使我不需要在我的观点中滚动。

我已经看到了WhatsApp应用类似的东西。

下面是一个链接,看看我想要什么:

在这里输入的形象描述

我的code:

 <?XML版本=1.0编码=UTF-8&GT?;
< android.support.design.widget.CoordinatorLayout
的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto的xmlns:工具=htt​​p://schemas.android.com/tool​​s的android:layout_width =match_parent
机器人:layout_height =match_parent机器人:fitsSystemWindows =真
工具:上下文=com.example.yasser.version6.Profile>< android.support.design.widget.AppBarLayout机器人:ID =@ + ID / app_bar
    机器人:fitsSystemWindows =真正的机器人:layout_height =@扪/ app_bar_height
    机器人:layout_width =match_parent安卓主题=@风格/ MyMaterialTheme.AppBarOverlay>    < android.support.design.widget.CollapsingToolbarLayout机器人:ID =@ + ID / toolbar_layout
        机器人:fitsSystemWindows =真的android:layout_width =match_parent
        机器人:layout_height =match_parent应用程序:layout_scrollFlags =滚动| exitUntilCollapsed
        应用:contentScrim =?ATTR / colorPrimary>        < ImageView的
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            机器人:scaleType =centerCrop
            机器人:SRC =@绘制/ TOF/>        < android.support.v7.widget.Toolbar机器人:ID =@ + ID /工具栏
            机器人:layout_height =?ATTR / actionBarSize的android:layout_width =match_parent
            应用:layout_collapseMode =针
            应用:popupTheme =@风格/ MyMaterialTheme.PopupOverlay/>    < /android.support.design.widget.CollapsingToolbarLayout>
< /android.support.design.widget.AppBarLayout>
<包括
    机器人:ID =@ + ID /内容
    布局=@布局/ content_profile/>
< /android.support.design.widget.CoordinatorLayout>

内容简介code:

 <?XML版本=1.0编码=UTF-8&GT?;
< android.support.v4.widget.NestedScrollView
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto
    应用:layout_behavior =@字符串/ appbar_scrolling_view_behavior
    的xmlns:card_view =htt​​p://schemas.android.com/apk/res-auto
    工具:舒=@布局/ activity_profile的android:layout_width =match_parent
    机器人:layout_height =match_parent工具:上下文=com.example.yasser.version6.Profile>
< /android.support.v4.widget.NestedScrollView>


解决方案

下面是一个例子:

https://github.com/saulmm/CoordinatorBehaviorExample

使用这样的:

 < android.support.design.widget.CollapsingToolbarLayout
                机器人:ID =@ + ID / main.collapsing
                机器人:layout_width =match_parent
                机器人:layout_height =WRAP_CONTENT
                应用:layout_scrollFlags =滚动| exitUntilCollapsed>                < ImageView的
                    机器人:ID =@ + ID / main.imageview.placeholder
                    机器人:layout_width =match_parent
                    机器人:layout_height =300dp
                    机器人:scaleType =centerCrop
                    机器人:SRC =@绘制/ quila2
                    机器人:色调=#11000000
                    应用:layout_collapseMode =视差
                    应用:layout_collapseParallaxMultiplier =0.9/>

I'm trying to make a CollapsingToolbarLayout scrolling always even if I don't need to scroll on my view.

I have seen something similar in WhatsApp application.

Here is a link to see what I want :

My code :

<?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"
tools:context="com.example.yasser.version6.Profile">

<android.support.design.widget.AppBarLayout android:id="@+id/app_bar"
    android:fitsSystemWindows="true" android:layout_height="@dimen/app_bar_height"
    android:layout_width="match_parent" android:theme="@style/MyMaterialTheme.AppBarOverlay">

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

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:src="@drawable/tof" />

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

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




<include
    android:id="@+id/content"
    layout="@layout/content_profile" />


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

Content profile code :

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    tools:showIn="@layout/activity_profile" android:layout_width="match_parent"
    android:layout_height="match_parent" tools:context="com.example.yasser.version6.Profile">


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

解决方案

Here is an example:

https://github.com/saulmm/CoordinatorBehaviorExample

Use it like this:

<android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/main.collapsing"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <ImageView
                    android:id="@+id/main.imageview.placeholder"
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/quila2"
                    android:tint="#11000000"
                    app:layout_collapseMode="parallax"
                    app:layout_collapseParallaxMultiplier="0.9" />

这篇关于(设计支持库)CollapsingToolbarLayout如何使它始终滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆