I have an image that is too big to fit on the screen, and I want it fairly small on screen. How do I change the size of the image through XML?
I tried:
<ImageView android:id="@+id/image" android:layout_width = "100dp" android:layout_height= "100dp" android:scaleType="center" android:layout_gravity="center_horizontal|bottom" android:src="@drawable/dashboard_rpm_bottom" > </ImageView>
But the image isn't resized... it gets cropped. Any ideas?
This example demonstrate about How to resize Image in Android App. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
for example:
<ImageView android:id="@+id/image_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:maxWidth="42dp" android:maxHeight="42dp" android:scaleType="fitCenter" android:layout_marginLeft="3dp" android:src="@drawable/icon" />
Add property android:scaleType="fitCenter"
and android:adjustViewBounds="true"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With