android - 完整图像不会显示在 CardView 中

标签 android android-studio android-imageview android-cardview

我在 Android Studio 中使用 CardView ,我想在其中使用 ImageView 来显示一些图像,但问题是它不显示完整图像。我想缩放它以显示完整图像。

这是我的代码的一部分:

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/card_margin"
            android:layout_marginLeft="@dimen/card_margin"
            android:layout_marginRight="@dimen/card_margin">

            <LinearLayout
                style="@style/Widget.CardContent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="more"
                    android:textAppearance="@style/TextAppearance.AppCompat.Title" />

                <a.extera.CustomTxtView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/txt_more"
                    android:lineSpacingExtra="7dp"
                    android:textSize="18dp"
                    android:text="more" />

                <ImageView
                    android:id="@+id/backdrop1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="centerInside"
                    android:fitsSystemWindows="true"
                    android:orientation="vertical"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true"
                />

                <a.extera.CustomTxtView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/txt_more2"
                    android:lineSpacingExtra="7dp"
                    android:textSize="18dp"
                    android:text="more" />

                <ImageView
                    android:id="@+id/backdrop2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="centerInside"
                    android:fitsSystemWindows="true"
                    android:layout_centerVertical="true"
                    android:layout_centerHorizontal="true"
                    android:orientation="vertical"
                    app:layout_collapseMode="parallax"
                  />

                <a.extera.CustomTxtView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/txt_more3"
                    android:lineSpacingExtra="7dp"
                    android:textSize="18dp"
                    android:text="more" />

                <ImageView
                    android:id="@+id/backdrop3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="centerInside"
                    android:fitsSystemWindows="true"
                    android:layout_centerVertical="true"
                    android:layout_centerHorizontal="true"
                    android:adjustViewBounds="true"
                    android:orientation="horizontal"
                    app:layout_collapseMode="parallax" />

                <a.extera.CustomTxtView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/txt_more4"
                    android:lineSpacingExtra="7dp"
                    android:textSize="18dp"
                    android:text="more" />


                <ImageView
                    android:id="@+id/backdrop4"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="centerInside"
                    android:fitsSystemWindows="true"
                    android:layout_centerVertical="true"
                    android:layout_centerHorizontal="true"
                    android:orientation="vertical"
                    app:layout_collapseMode="parallax"
                    android:adjustViewBounds="false" />

                <a.extera.CustomTxtView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/txt_more5"
                    android:lineSpacingExtra="7dp"
                    android:textSize="18dp"
                    android:text="more" />

                <ImageView
                    android:id="@+id/backdrop5"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="centerInside"
                    android:layout_centerVertical="true"
                    android:layout_centerHorizontal="true"
                    android:orientation="vertical"
                    android:fitsSystemWindows="true"
                    app:layout_collapseMode="parallax"
                    android:adjustViewBounds="false" />

            </LinearLayout>

        </android.support.v7.widget.CardView>

for example this is the full image:

! https://s32.postimg.org/mntlijbn9/a_2.jpg

this is what it shows:

! https://s32.postimg.org/s6fyuyd91/image.jpg

最佳答案

将 ImageView 中的 android:scaleType="centerInside" 更改为 android:scaleType="fitXY"

关于android - 完整图像不会显示在 CardView 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38681094/

相关文章:

android - 包含带有 android flavor 的库

android - 更新我的应用程序时 Android 完全崩溃

android - 没有 google-services.json,Google 服务插件无法运行

java - 我如何从文本时钟中获取值

带动画的 Android 缩放 ImageView

android - 设备所有者 QR 停止在 Android12 设备上工作,获取无法设置设备消息

android - View 绑定(bind)无权访问 fragment

android - 无法解析 jitpack.io 依赖项

android - 图像在另一台设备上模糊

Android:获取ImageView上的触摸位置点