【问题标题】:android - Change image position in imageview using glideandroid - 使用滑行更改图像视图中的图像位置
【发布时间】:2015-11-26 22:39:40
【问题描述】:

我正在使用 Glide 壁纸应用程序 我用 glide 加载图像并在 imageview 中显示,但是加载后的图像在 imageview 的顶部。

我怎样才能解决这个问题并将其置于 imageview 的中心?

代码:

Glide.with(this)
      .load(data)
      .fitCenter()
      .into(wallpaper);

XML:

<ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/img_aksneveshte"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

【问题讨论】:

  • 请输入您的xml代码
  • 您确定您的ImageView 横跨整个屏幕高度吗?另外,请仔细检查您没有启用类似adjustViewBounds 的功能。按照建议,如果您添加相关布局文件的内容,我们可以提供更多帮助。
  • 我更新了帖子。 adjustViewBounds 不起作用

标签: android android-imageview android-glide


【解决方案1】:

即使你有答案,我也可以提供更多信息

Glid 可以使用在您的图像视图中分配的比例类型

android:scaleType="centerCrop"

所以把它添加到你的 ImageView 中

变成这样

<ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/img_aksneveshte"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:scaleType="centerCrop"
        />

这里是 Glid 读取刻度类型和use it

    if (!isTransformationSet && view.getScaleType() != null) {
                switch (view.getScaleType()) {
                    case CENTER_CROP:
// in case you set image scale center crop
                        applyCenterCrop();
                        break;
                    case FIT_CENTER:
                    case FIT_START:
                    case FIT_END:
                        applyFitCenter();
                        break;
                    //$CASES-OMITTED$
                    default:
                        // Do nothing.
                }
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多