我有一个CoordinatorLayout,它包含一个ViewPager,该控件使用嵌套的滚动行为可以正常滚动。 但是,我想在单击按钮时触发滚动/折叠行为。 如何通过单击按钮来控制这种崩溃行为。

通过获得控件,我将能够控制如何以及何时折叠整个视图,以在Tablet横向视图上获得更多空间。 任何有用的答案将非常令人高兴。

这是我的xml代码:

xmlns:application="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:orientation="vertical"

tools:context=".view.fragment.ItemDetailFragment">

android:id="@+id/appBarLayout"

android:layout_width="match_parent"

android:layout_height="@dimen/app_bar_height"

android:theme="@style/AppTheme.AppBarOverlay"

application:layout_constraintLeft_toLeftOf="parent"

application:layout_constraintRight_toRightOf="parent">

android:id="@+id/collapse_toolbar"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true"

application:contentScrim="?attr/colorPrimary"

application:layout_scrollFlags="scroll|exitUntilCollapsed|snap"

application:titleEnabled="false">

android:id="@+id/item_detail"

style="?android:attr/textAppearanceLarge"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:fitsSystemWindows="true"

android:paddingStart="@dimen/padding_16"

android:paddingTop="@dimen/padding_4"

android:textColor="@android:color/white"

android:textIsSelectable="true"

android:textStyle="bold"

application:layout_collapseMode="parallax"

tools:ignore="RtlSymmetry" />

android:id="@+id/appRecycler"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_horizontal|center_vertical"

android:fitsSystemWindows="true"

application:layout_collapseMode="parallax"

tools:listitem="@layout/app_item" />

android:id="@+id/htab_toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:layout_gravity="top"

application:layout_collapseMode="pin"

application:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

android:id="@+id/tabLayout"

android:layout_width="match_parent"

android:layout_height="@dimen/tab_height"

android:layout_gravity="bottom"

android:layout_marginLeft="@dimen/margin_48"

android:layout_marginRight="@dimen/margin_48"

android:minHeight="?actionBarSize"

application:layout_constraintTop_toTopOf="@id/appBar"

application:tabBackground="@color/primary"

application:tabGravity="fill"

application:tabIndicator="@color/white"

application:tabIndicatorColor="@color/white"

application:tabIndicatorHeight="@dimen/tab_indicator_height"

application:tabMode="scrollable"

application:tabSelectedTextColor="@color/white"

application:tabTextAppearance="?android:textAppearanceSmall" />

android:id="@+id/viewpager"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_marginLeft="@dimen/margin_48"

android:layout_marginTop="@dimen/margin_32"

android:layout_marginRight="@dimen/margin_48"

android:layout_marginBottom="@dimen/margin_100"

application:layout_behavior="@string/appbar_scrolling_view_behavior" />

```

Android消息向下堆积,android - 从CoordinatorLayout中的按钮单击事件触发NestedScroll折叠动作 - 堆栈内存溢出...相关推荐

  1. android 推送的小图标,android - 推送通知中没有声音并且没有自定义的小图标 - 堆栈内存溢出...

    我已经使用Firebase Cloud Messaging实现了推送通知,除了几个自定义问题之外,其他所有功能都正常运行: 当我从Notification Composer工具发送测试通知时,清单中设 ...

  2. android 三星 oom,android - 终结者抛出未捕获的异常:谷歌API错误或三星内核错误? - 堆栈内存溢出...

    在我的Galaxy Tab 2(三星)上启动我的应用程序时,我一直收到此错误. 我正在开发的应用程序非常复杂,很难找到此错误源自何处. 所以我开始逐个删除我的应用程序,我最终得到了一个mapview应 ...

  3. android studio按钮点击事件,如何在Android Studio中添加按钮单击事件

    因此,我进行了一些研究,并在代码中将按钮定义为对象之后 private Button buttonname; buttonname = (Button) findViewById(R.id.butto ...

  4. Android 找不到资源异常,cordova - 离子3错误:找不到资源xml / network_security_config - 堆栈内存溢出...

    当我尝试运行" ionic cordova build android"时,出现以下异常: 匿名资源链接失败J:\\ workspaces \\ APCO \\ App \\ ap ...

  5. linux下java调用python脚本,java - 在Linux Terminal中以编程方式从Java调用python脚本 - 堆栈内存溢出...

    我正在开发一个Java应用程序,用于检查源文件中的补丁程序(是否存在). 用于检测补丁程序更改的核心逻辑位于python脚本[titled'patch.py​​']中,并且我的Java应用程序与此Py ...

  6. [Android] 按钮单击事件的五种写法

    在平时学习安卓的过程中,不论是看视频还是看博客,我发现每个人对代码的写法都有不同的偏好,比较明显的就是对控件响应事件的写法的不同.所以我想把这些写法总结一下,比较下各种写法的优劣,希望可以让自己可以灵 ...

  7. android 5 .0下拉回弹,自定义CoordinatorLayout.Behavior 实现下拉回弹

    先看效果 123.gif package com.tospur.exmind.testrecycerviewwithtopandbottomrefresh.refresh; import androi ...

  8. Android 消息机制详解(Android P)

    前言 Android 消息机制,一直都是 Android 应用框架层非常重要的一部分,想更加优雅的进行 Android 开发,我想了解消息机制是非常必要的一个过程,此前也分析过很多次 Handler ...

  9. android ?attr得到状态栏高度,android - 状态栏下方的CoordinatorLayout + CollapsingToolbarLayout滚动 - 堆栈内存溢出...

    我的布局有一个奇怪的问题. 我有一个带有CollapsingToolBarLayout的CoordinatorLayout . 我有一个透明的状态栏,可以在顶部更好地显示图像. 因此,我在此Image ...

最新文章

  1. P1051 谁拿了最多奖学金
  2. linux nm工具 查看静动态库导出函数
  3. Jenkins之gitlab配置
  4. 历史和现代的碰撞和思考
  5. IdentityServer4 之 Resource Owner Password Credentials 其实有点尴尬
  6. 质量体系审核中的10大常见场景,你遇到了几个?
  7. 剑指Offer - 面试题24. 反转链表(遍历/递归)
  8. C++常用字符串分割方法
  9. 30-10-010-编译-IDEA下编译kafka 2.3源码
  10. win10计算机管理如何分区,windows10如何对电脑硬盘进行分区
  11. 必备读论文的黑科技!错过后悔!
  12. 交友盲盒小程序版本 全开源版本
  13. 计算机bios设置系统安装教程,U盘装系统BIOS设置教程进行设置图文教程
  14. 一文看懂数字孪生,工信部权威白皮书
  15. Android之音频和视频的提取
  16. UOS 操作蓝牙、wifi开关
  17. 我国跨国企业外汇风险管理——以海尔公司为例
  18. C++:编程题:魔兽世界之一:备战
  19. 线程的同步与互斥:互斥锁
  20. 股权控制权的五种设计策略

热门文章

  1. 我的工作日报 - 2020-9-15 星期二
  2. Angulary应用依赖里的zone.js
  3. SAP CRM呼叫中心polling and C4C notification polling
  4. 介绍一种Fiori标准应用的增强方式
  5. 如何在SAP gateway系统配置路由到后台系统的OData服务路径
  6. how does SAP ui5 know the phone, tablet type, os type
  7. CRM呼叫中心采用轮询和SNS服务器两种方式的架构
  8. how do you usually upload picture in SCN A workaround for current SCN upload is
  9. SAP CRM WebUI Opportunity belongs to me的处理逻辑
  10. SAP CRM Fiori My task应用里roundtrip取舍的讨论