在ImageView上滚动ScrollView

时间:2015-10-12 14:33:45

标签: android user-interface scrollview

我需要通过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>

1 个答案:

答案 0 :(得分:1)

如果我从您的说明和您提供的YouTube链接中正确理解,我认为此库适合您,https://github.com/umano/AndroidSlidingUpPanel。它是一个令人惊叹的库,您可以在其中定义两个布局,其中一个布局可以全屏显示图像,另一个布局可以是您的滚动视图。这样您就可以获得与您正在寻找的完全相同的效果。此外,您可以控制滚动视图布局,并使其像屏幕中间或底部一样稳定。用户可以将其拖动到全屏或将其固定在中间。试一试,如果您有任何困难,请告诉我们。

相关问题