ImageView中的图像显示非常模糊

问题描述 投票:0回答:1

我正在尝试开发一个小型的Android应用程序,该应用程序将使用图像识别技术来识别狗的品种。识别出一条狗后,它将在另一项活动中保存该品种的名称以及图片。那些被保存在MaterialLineView中,后者在Linearlayout内部,带有用于图像的ImageView,用于删除的TextView和ImageButton。在预览窗口中,一切看起来都很好:Preview Window,但是当我在手机上进行测试时,图像非常模糊或放大了,我什至不知道该如何描述:Actual app。我尝试了很多图片,也尝试了我在网上看到的大多数解决方案,但没有任何效果。我也是android的初学者,所以它可能很简单,我只是看不到。这是布局的xml代码:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        >


    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="15dp"
            android:elevation="15dp"
            android:orientation="horizontal"
            >
        <ImageView
                android:layout_width="150dp"
                android:layout_height="150dp"
                android:adjustViewBounds="true"
                android:scaleType="fitXY"
                android:src="@drawable/affenpinscher"
                android:id="@+id/img_content"

            />

        <TextView
                android:id="@+id/txv_content"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:layout_weight="100"
                android:gravity="center"
                android:padding="4dp"
                android:textSize="14sp"
                />
        <ImageButton
                android:id="@+id/ibt_delete"
                android:layout_width="30dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:textStyle="bold"
                android:background="@android:color/transparent"
                android:src="@android:drawable/ic_delete"
                />


    </LinearLayout>

</com.google.android.material.card.MaterialCardView>

[也尝试过android:scaleType =“ centerCrop”或只是“ center”,都是一样的。图片为220x330

android android-layout imageview android-imageview
1个回答
0
投票

图像模糊,因为它的分辨率大于当前尺寸的imageView支持的分辨率。

所以您必须调整图像大小。转到IDE设置->插件->搜索“ Android Drawable Importer并安装它->重新启动IDE安装后,右键单击可绘制文件夹,然后:新建->批量可绘制导入->选择图像并调整其大小。

© www.soinside.com 2019 - 2024. All rights reserved.