Reputation: 24573
I have an image view:
<?xml version="1.0" encoding="utf-8"?>
<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/image"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
If I have a pic show I use glide and the pic takes up the entire view as it should:
ImageView iv = (ImageView) findViewById(R.id.image);
Glide.with(getApplicationContext())
.load(path)
.centerCrop()
.into(iv);
However sometimes I don't have a picture and I just want to show an icon. The icon is a resource. I want the icon to be centered in the image view but I do not want the icon to take up the entire view (it will be way too big). I am trying to use the override method to make the icon much small in the view.
Glide.with(getApplicationContext()) .load(R.drawable.ic_picture_icon) .override(250, 250) .skipMemoryCache(true) // just for testing so it doesn't pull from cache .diskCacheStrategy(DiskCacheStrategy.SOURCE) // again just for testing .into(iv);
However I cannot get this to work. Is what I am trying to do possible? If so what am I doing wrong. Thanks in advance.
Upvotes: 0
Views: 1154
Reputation: 849
Changing the ImageView layout_height and layout_width to wrap_content should solve the problem.
Upvotes: 1