I have a LinearLayout with width set to fill_parent and height to wrap_content. Now I want to give it a background from a png file, but doing it in a traditional way causes the LinearLayout to resize in order to show the whole background instead of cropping the additional part.
How can I set the background of LinearLayout so it won't resize?
Thanks
Download the remove.bg Android app to your phone. Open it up. Now go ahead and select the image of which you want to remove the background from your library. Removing the background of your photo will only take a few seconds, you can also change the background to a different color or add another image from our presets.
Here's our top five best apps to remove background from photo for iPhone and Android in 2022: YouCam Perfect: Best Free Background Remover. PhotoCut Remove Background PNG. Magic Eraser Background Editor.
It appears that such thing is achievable only using the ImageView and setting the scaleType parameter accordingly. A quick workaround is to use FrameLayout and put the ImageView under another layout with transparent background.
Code:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/background" /> </FrameLayout>
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