7

I'm testing the glide for loading the images in 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 the image with the 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 glide the image get expanded ignoring the wrap_content layout params:

@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?

Addev
  • 31,819
  • 51
  • 183
  • 302
  • 1
    set `android:ScaleType="fitXY"` and try – M D Jul 22 '15 at 11:12
  • With fitXY the result is like in the first capture, but with an smaller image (maybe it is ignoring scaling the image up due to the screen density?) – Addev Jul 22 '15 at 11:24

0 Answers0