4

I made a linear layout with a background image, a png... I don't know how to show it into the layout ( and centered ) keeping 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 image has the same height and width of the display... Any help?? Thanks in advance

=.4.S.=

Erenwoid
  • 983
  • 6
  • 13
  • 25
  • Is the problem that the image is showing up skewed (wrong proportions), not filling the entire region of the LinearLayout, not centered, or some combination of the three? – plainjimbo Jun 06 '11 at 20:48
  • well, the image fill the entire region and is centered but has wrong proportions, because it's anchored to the layout... – Erenwoid Jun 06 '11 at 20:54

3 Answers3

8

Thank you all ^^ I solved in 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>
Erenwoid
  • 983
  • 6
  • 13
  • 25
0

If you do not want your picture to be stretched, you can use BitmapDrawable with gravity set us instead of png.
Refer docs: Bitmap

woodshy
  • 4,085
  • 3
  • 22
  • 21
0

Try this related question/answer:

Android: Scale a Drawable or background image?

I haven't tried it, but it sounds similar to what you're talking about.

Community
  • 1
  • 1
plainjimbo
  • 7,070
  • 9
  • 41
  • 55