1

我试图使图像内部CollapsingToolbarLayout可滚动(就像在 Google Play 应用程序中一样)。然后我把NestedScrollView里面CollapsingToolbarLayout。ImageView 强制调整自身大小(见图)(图像失真)。如何使这个东西正常工作?

在此处输入图像描述

我的布局

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:fitsSystemWindows="true"
        app:contentScrim="@color/pure_black75"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">
        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:background="@color/transparent"
            android:maxHeight="200dp"
            android:height="200dp"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp"
            android:layout_height="match_parent">
        <ImageView
            android:id="@+id/backdrop"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitXY"
            android:src="@drawable/cat_stub"
            app:layout_collapseMode="parallax" />
        </android.support.v4.widget.NestedScrollView>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:queryBackground="@android:color/transparent"
            app:layout_collapseMode="pin" />


        </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:background="@color/transparent"
    android:maxHeight="200dp"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">


    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="230dp"
            android:scaleType="fitXY"
            android:src="@drawable/cat_stub"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="230dp"
            android:scaleType="fitXY"
            android:src="@drawable/cat_stub"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="230dp"
            android:scaleType="fitXY"
            android:src="@drawable/cat_stub"/>


    </LinearLayout>
</android.support.v4.widget.NestedScrollView>



<SeekBar
    android:layout_marginLeft="-18dp"
    android:layout_marginRight="-18dp"
    android:id="@+id/audio_seekbar"
    app:layout_anchor="@id/appbar"
    app:layout_anchorGravity="bottom"
    android:thumb="@null"
    android:layout_width="match_parent"
    android:indeterminateDrawable="@drawable/apptheme_scrubber_progress_horizontal_holo_light"
    android:progressDrawable="@drawable/apptheme_scrubber_progress_horizontal_holo_light"
    android:layout_above="@id/video_play_pause"
    android:layout_height="wrap_content"/>
<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:id="@+id/fab_play_pause"
    android:height="20dp"
    app:layout_anchor="@id/appbar"
    app:layout_anchorGravity="bottom|right|end"
    android:minHeight="0dp"
    android:scaleType="fitXY"
    android:src="@drawable/fab_play_pause_selector"
    app:layout_collapseMode="pin"
    android:layout_marginTop="4dp"
    android:padding="5dp"
    app:backgroundTint="@color/white"
    app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
    android:layout_height="wrap_content"/>

4

1 回答 1

0

您可以尝试更改 scaleType centerCrop:

        <ImageView
            android:id="@+id/backdrop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            app:layout_collapseMode="parallax" />
于 2015-07-24T09:52:52.823 回答