The background image in the linear layout has no size

I made a linear layout with a background image, png ... I don’t know how to show it in the layout (and in the center), keeping the proportions ... here is the code

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background"> 

Obviously the image has the same height and width of the display ... Any help? thanks in advance

=. 4.S. =

+4
source share
3 answers

Try this related question / answer:

Android: scale graphic or background image?

I have not tried it, but it looks like what you are talking about.

0
source

Thanks to everyone ^^ I decided this way:

 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/background" android:layout_gravity="center"/> <ListView android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="#FFFFFF" android:layout_weight="2" android:drawSelectorOnTop="false" android:layout_gravity="center"/> </FrameLayout> 
+8
source

If you do not want the image to be stretched, you can use BitmapDrawable with gravity to set us instead of png.
See Documents: Bitmap

0
source

All Articles