在 ImageView 上滚动 ScrollView
Scroll ScrollView over ImageView
我需要在 ScrollView 上方的静态 ImageView 上滚动 ScrollView 中的内容。当 ImageView 会消失时,ScrollView 需要正常滚动。效果与 CollapsingToolbarLayout 相同,但我需要在不使用 actionbar 且没有效果的情况下执行此操作。
点赞 - 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 link 中理解正确,我认为这个库对你有用,https://github.com/umano/AndroidSlidingUpPanel。它是一个了不起的库,您可以在其中定义两种布局,一种可以是全屏显示图像视图的布局,另一种可以是带有滚动视图的布局。这样你就可以得到你正在寻找的完全相同的效果。此外,您可以控制您的滚动视图布局,并可以让它固定在屏幕中间或底部。用户可以将其拖动到全屏或将其固定在中间。试一试,如果您有任何困难,请告诉我们。
我需要在 ScrollView 上方的静态 ImageView 上滚动 ScrollView 中的内容。当 ImageView 会消失时,ScrollView 需要正常滚动。效果与 CollapsingToolbarLayout 相同,但我需要在不使用 actionbar 且没有效果的情况下执行此操作。
点赞 - 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 link 中理解正确,我认为这个库对你有用,https://github.com/umano/AndroidSlidingUpPanel。它是一个了不起的库,您可以在其中定义两种布局,一种可以是全屏显示图像视图的布局,另一种可以是带有滚动视图的布局。这样你就可以得到你正在寻找的完全相同的效果。此外,您可以控制您的滚动视图布局,并可以让它固定在屏幕中间或底部。用户可以将其拖动到全屏或将其固定在中间。试一试,如果您有任何困难,请告诉我们。