Reputation: 7519
I have set these properties of an ImageView
<ImageView
android:id="@+id/image_view"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHorizontal_bias="0.0"
android:adjustViewBounds="true"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
app:layout_constraintBottom_toBottomOf="parent"
android:scaleType="centerCrop"
/>
Now from Java code, I want to remove scaleType
property form this image view. I dont want any scale type to be on this ImageView.
Is it possible to achieve this?
Upvotes: 1
Views: 194
Reputation: 3398
If You Not Set Any Scale Type Then For Image View Default Scale Type is FIT_CENTER
//So to remove other scale types and set to default use
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
Upvotes: 3
Reputation: 2030
This is how you set or change the Image View scale type at runtime from within Java:
ImageView imageView = (ImageView) findViewById(R.id.image_view);
imageView.setScaleType(ScaleType.CENTER);
You can refer to this documentation page for the possible ScaleType options.
Upvotes: 1