- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 CountryActivityInfo.java
中,我有一个折叠工具栏,其宽度和高度都设置为 match-parent
,因此它可以占据整个手机屏幕。当我向上滚动时,工具栏会获得固定的 200dp
高度。
现在,它看起来像这样:
我想在工具栏折叠时出现的白色屏幕中显示一个内部有 TextView 的垂直 ScrollView 。我怎样才能做到这一点?我已经尝试过这种方法:
<android.support.design.widget.AppBarLayout
android:id="@+id/testeparainfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/actionBarDivider">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/backgroundcollapsedtoolbarinfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="exitUntilCollapsed|scroll">
<ImageView
android:id="@+id/imgCountryInfoFoto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/imgCountryInfoEscuro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@drawable/background_pais_info"
android:scaleType="centerInside" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbaridinfo"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<TextView
android:id="@+id/txtNomePaisInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="30dp"
android:layout_marginTop="520dp"
android:paddingBottom="10dp"
android:text="TextView"
android:textColor="@android:color/background_light"
android:textSize="35sp"
app:layout_anchor="@+id/testeparainfo"
app:layout_anchorGravity="left|bottom" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/txtInfoPais"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="@+id/btnArrowBackWhite"
android:layout_marginBottom="111dp"
android:text="TextView"
android:textColor="@android:color/background_light"
android:textSize="15sp"
android:visibility="invisible"
app:layout_anchor="@+id/imgCountryInfoFoto"
app:layout_anchorGravity="bottom|center" />
</LinearLayout>
</ScrollView>
但是,当我这样做时, TextView 会进入折叠工具栏并与工具栏一起折叠。顺便说一句,所有 XML 都包含在 Coordinator Layout
中!!!
最佳答案
将根更改为CoordinatorLayout
<?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.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_scrolling" />
</android.support.design.widget.CoordinatorLayout>
然后在 content_scrolling.xml
中使用 NestedScrollView
和 app:layout_behavior="@string/appbar_scrolling_view_behavior"
使用此属性来实现正确的行为。
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
...
</android.support.v4.widget.NestedScrollView>
关于java - CollapsingToolBar 不起作用后添加 ScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51172865/
我试图在展开或折叠折叠工具栏时显示标题。然而,在任何这些状态下,标题总是有一个移动动画: 如何完全摆脱动画并使标题停留在一个位置? 我试过将 titleEnabled 设置为 false,但这只会禁用
我正在尝试创建一个 CollapsingToolbarLayout,其中有一张电影海报与背景重叠。为了实现这一点,我启用了behavior_overlapTop =“67dp”,但这会导致奇怪的滚动行
我有一个 Navigation Drawer Activity (NavActivity),其中一个 fragment (OuterFrag.xml) 有一个 Collapsing Toolbar 和
我很确定这是一个错误,所以我正在寻求解决方法。我的布局是这样的: 我正在从网
在我的 CountryActivityInfo.java 中,我有一个折叠工具栏,其宽度和高度都设置为 match-parent,因此它可以占据整个手机屏幕。当我向上滚动时,工具栏会获得固定的 200
基本上,我想知道如何在使用 RecyclerView 时,如何实现一种“动画 CollapsingToolbar”。请注意,它用引号引起来,因为我没有附加到 CollapsingToolbar 的解决
我正在使用 android 支持设计 'com.android.support:design:22.2.1' 我的问题是当滚动没有内容时,折叠工具栏仍然启用折叠操作。如果滚动中没有内容,我需要删除 V
简而言之: Is this a collapsing toolbar or a Persistent Bottom Sheet? 起初我认为这是一个折叠工具栏,但在折叠工具栏上向上滚动不是那么平滑,并
我已经遇到过这个问题: MainActivity 的标题隐藏了选项卡。你能告诉我如何改变它的位置吗? Here is an XML code:
我需要知道 Material 设计库中的 CollapsingToolbar 何时折叠。 最佳答案 正如 Marko 所说,这可以使用您自己的 OnOffsetChangedListener 实现来实
如何为 RTL 语言添加一些填充到 collapsingToolbar 标题中,这对 LTR 语言很好,但对 RTL 就像下面这样.. 非常感谢 这是我的布局..正如您在上图右侧看到的那样,标题没有任
这就是我想要实现的,在 CollapsingToolbar 中的图像下方将有一个自定义布局,该布局将包含几个 View 项。 1 所需的行为是,在滚动时,底部布局会逐渐淡化和消失,顶部的图像会缩小并固
Android 中的ToolBar 和CollapsingToolBar 有什么区别?我试着在网上找到它,但找不到任何有用的资源 最佳答案 工具栏看起来像这样: 您可以将它移动到屏幕上任何您想要的位置
正如标题所暗示的,我有一个具有 FrameLayout 的 Activity 那是我的Fragments [我没有使用标签,只是交易]。我还有一个 NavigationDrawer和 Toolbar
我为 TextView 开发了一些自定义行为根据 AppBarLayout 的高度改变位置和大小在 CoordinatorLayout 里面.这样一来,标题就显得很大,并且位于完全展开的 Toolba
我的布局有一个标题部分,标题部分下面有一个图标和文本。在标题下的嵌套 ScrollView 中有更多描述(如下所示)。 当用户滚动查看更多描述时,我希望图标慢慢消失,标题文本保留在原位。但是我不确定该
如何在 Android 的折叠工具栏布局中设置标题和子标题,如 whatsapp 个人资料 View 。 我附上了相同的示例屏幕截图。 最佳答案 我终于得到了答案。请检查链接。这就是我要的。 http
我正在开发一款采用 Material Design 的 Android 应用。我有一个带有 CollapsingToolbarLayout 和 ImageView 的详细 View (到目前为止工作正
我有一个折叠式工具栏布局,如下所示: circle_image_view 在哪里 这只是一个带有圆形 mask 的标准 ImageView 。当
我正在开发像 UBER 这样的应用程序。自定义标记的第一次滚动在 map 上运行良好。之后我像 UBER 一样添加了 NestedScrollView。但是 map 滚动手势与 AppBar 滚动行为
我是一名优秀的程序员,十分优秀!