gpt4 book ai didi

android - 在 ImageView 上滚动 ScrollView

转载 作者:行者123 更新时间:2023-11-30 01:50:46 25 4
gpt4 key购买 nike

我需要在 ScrollView 上方的静态 ImageView 上滚动 ScrollView 中的内容。当 ImageView 会消失时,ScrollView 需要正常滚动。效果与 CollapsingToolbarLayout 相同,但我需要在不使用操作栏且不使用效果的情况下执行此操作。

点赞 - https://www.youtube.com/watch?t=23&v=FTRpemXF3_8

我的布局文件:

<ImageView
android:id="@+id/full_image"
android:layout_width="match_parent"
android:layout_height="@dimen/full_image_height"
android:scaleType="centerCrop"
android:src="@mipmap/logo" />

<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/full_image_height">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="8dp"
android:padding="@dimen/text_margin">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="@dimen/small_margin"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/title"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_marginLeft="@dimen/small_margin"
android:layout_toEndOf="@+id/date"
android:layout_toRightOf="@+id/date"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/colorAccent" />

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/date"
android:layout_marginTop="@dimen/small_margin"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>

</ScrollView>

最佳答案

如果我从你的描述和你提供的 youtube 链接中理解正确,我认为这个库对你有用,https://github.com/umano/AndroidSlidingUpPanel .它是一个了不起的库,您可以在其中定义两种布局,一种可以是全屏显示 ImageView 的布局,另一种可以是带有 ScrollView 的布局。这样你就可以得到你正在寻找的完全相同的效果。此外,您可以控制您的 ScrollView 布局,并可以让它固定在屏幕中间或底部。用户可以将其拖动到全屏或将其固定在中间。试一试,如果您有任何困难,请告诉我们。

关于android - 在 ImageView 上滚动 ScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33083774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com