简体   繁体   English

活动开始时折叠式工具栏布局将自动变为折叠状态

[英]Collapsing toolbar layout is going to collapsed state automatically on start of activity

I have a collapsing toolbar within an appbar layout. 我在应用栏布局中有一个折叠式工具栏。 It contains a view pager as it's collapsing content and a pinned action toolbar. 它包含折叠内容的视图寻呼机和固定操作工具栏。 The activity also has a nested scroll view below the collapsing toolbar. 活动在折叠的工具栏下方还有一个嵌套的滚动视图。 The nested scroll view contains a google map fragment. 嵌套的滚动视图包含一个Google地图片段。

On start of the activity, the collapsing toolbar collapses automatically in some of the cases without programmatically collapsing it. 在活动开始时,在某些情况下,折叠工具栏会自动折叠,而无需以编程方式折叠它。

I have tried a combination of different scroll flags for my view with scroll|exitUntilCollapsed|enterAlways. 我已经尝试使用scroll | exitUntilCollapsed | enterAlways为我的视图组合了不同的滚动标志。 I have also tried not showing the google map fragment but I can still reproduce it. 我也尝试过不显示google map片段,但是我仍然可以复制它。

How can I stop it from collapsing automatically? 如何阻止它自动塌陷? Any help would be appreciated! 任何帮助,将不胜感激!

I know its late but still.. 我知道已经晚了,但是仍然..

The reason collapsing toolbar automatically collapses on actvity start is because there may a view in < include layout="@layout/content_scrolling" /> like edittext which gain its focus when activity is started.. 折叠式工具栏在活动启动时自动折叠的原因是,在< include layout =“ @ layout / content_scrolling” />中可能存在诸如edittext之类的视图,该视图在活动开始时会获得焦点。

To overcome this issue you can add the tag 要解决此问题,您可以添加标签

android:focusableInTouchMode="true" 机器人:focusableInTouchMode = “真”

to or 到或

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    xmlns:android="http://schemas.android.com/apk/res/android">

Hope it helps..:) 希望能帮助到你..:)

Happy Coding..:) 快乐编码.. :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM