ImageView wrap_content does not work with Glide

I am testing sliding to load images into my project.

I created the following layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:id="@+id/imageview" android:background="#550000ff" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> 

When I load an image using imageView.setImageResource(int) , it loads correctly (see screenshot below)

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView imageView= (ImageView) findViewById(R.id.imageview); imageView.setImageResource(R.drawable.pen_logo); } 

enter image description here

But when I load it with a slide, the image expands, ignoring the wrap_content options:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView imageView = (ImageView) findViewById(R.id.imageview); Glide.with(this).load(R.drawable.pen_logo).into(imageView); } 

enter image description here

How can I solve this problem?

+5
source share

All Articles