【问题标题】:Android Glide ImageView ScaleType Matrix CenteringAndroid Glide ImageView ScaleType 矩阵居中
【发布时间】:2017-08-07 14:20:39
【问题描述】:

我正在使用 Glide 4.0 将图像加载到具有 scaleType="matrix" 的 ImageView 中,以实现平移和缩放功能。图像未居中加载。如果它很高,则加载到左侧,如果它很宽,则加载到顶部(见图)。我已经尝试了各种 RequestOptions,但最初都没有将图像居中。我怎样才能做到这一点?谢谢!

Current Tall or Wide Image Position

活动

Uri selectedImage = returnedIntent.getData();
RequestOptions options = new RequestOptions().fitCenter();
Glide.with(MyActivity.this).load(selectedImage).apply(options).into(mImage);

布局

<ImageView
  android:id="@+id/m_image"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:scaleType="matrix" />

【问题讨论】:

  • 请在您的问题中添加代码 sn-p
  • @Danilo 更新了!谢谢!

标签: android imageview android-glide


【解决方案1】:

您正在使用 .apply(options) 覆盖 scaleType 属性的功能

只删除它,以便请求将 Glide.with(MyActivity.this).load(selectedImage).into(mImage);

您可能会发现此链接很有帮助 https://github.com/wasabeef/glide-transformations/issues/94

【讨论】:

    猜你喜欢
    • 2016-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多