ImageView Android中的图像像素失真

时间:2018-04-13 06:31:10

标签: android android-layout android-studio android-fragments android-imageview

我正在使用一个应用程序,其中我有更多的图像工作。我想在我的应用中显示个人资料图片和文章图片。对于文章图片,我尝试过ImageView到#34; fitcenter或centercrop或fitxy" 比例类型但没有什么工作。我的图像像素失真。我正在使用 Glide 库在服务器上显示图像。我甚至尝试了.fitcenter()等Glide方法但没有任何作用,因此我的图像可以正常使用ImageView

代码:

<ImageView
    android:id="@+id/imgArticle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    android:src="@drawable/blank_image" />

滑翔码:

Glide.with(context).load(articleList.get("article_image"))
        .thumbnail(0.5f)
        .placeholder(context.getResources().getDrawable(R.drawable.blank_image))
        .fitCenter()
        .into(imgBanner);

我尝试了各种方法,例如fitcenter,centercrop等,但没有任何效果。

Below is my image i.e. how its looks on device

1 个答案:

答案 0 :(得分:0)

android:scaleType="fitXY"会拉伸你的形象。您可以尝试使用此代码,以便图像不会拉伸。

<ImageView
    android:id="@+id/imgArticle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/blank_image" />

或者您可以根据用户界面调整高度和宽度

<ImageView
    android:id="@+id/imgArticle"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:src="@drawable/blank_image" />
相关问题