L. *_*ter 8 android imageview android-layout android-glide
我Glide在我的项目中加载了一张图片,但我发现了一件奇怪的事情.当我使用时into(ImageView),ImageView显示与使用时的显示不同into(new BitmapImageViewTarget(centerImageView)):
这是我的布局:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/center_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我用的时候:
String imageUrl = "http://7xlz1k.com1.z0.glb.clouddn.com/feedback-201604229711.png";
Glide.with(this).load(imageUrl).into(centerImageView);
Run Code Online (Sandbox Code Playgroud)
ImageView wrap_content不起作用,它显示如下:

但是当我使用时:
Glide.with(this).load(imageUrl).asBitmap().into(new BitmapImageViewTarget(centerImageView));
Run Code Online (Sandbox Code Playgroud)
ImageView看起来:
包含在其中的图像imageUrl是120*120的图片.
当我使用时BitmapImageViewTarget,默认动画不起作用.
三个问题:
为什么这两种方法有区别?
wrap_content在使用第一种方法时,如何使ImageView 有用?
如何在使用时启用默认动画BitmapImageViewTarget?
小智 6
我将尝试为您的第二个问题提供解决方案:
- 使用第一种方法时,如何使ImageView的wrap_content有用?
我设法通过将AdjustViewBounds添加到ImageView的布局中来使wrap_content起作用:
<ImageView
android:id="@+id/center_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2754 次 |
| 最近记录: |