Reputation: 1
I want the image to shrink or increase in size as i change the screen resolution. Please help!
When i changed the screen size the image became either too small or too big for some screen.
Just using some xml tags is it possible to achieve this. PS:NOOB ME
Upvotes: 0
Views: 261
Reputation: 21
You can do this:-
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/your_image"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
Make sure :-
android:layout_width="match_parent" ensures the image width matches the container. android:layout_height="wrap_content" lets the image adjust its height based on its aspect ratio. android:adjustViewBounds="true" and android:scaleType="fitCenter" further fine-tune scaling while maintaining aspect ratio.
Upvotes: 0