user3336884
user3336884

Reputation:

Background Relative layout

i would set background of my activity.

this is my layout (populate with list view)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:background="#FFFFFF" >

    <TextView
        android:id="@+id/girone"
        style="@style/NomeSquadra"
        android:layout_width="fill_parent"
        android:layout_height="20dip" />

    <TextView
        android:id="@+id/home"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/girone"
        android:layout_marginLeft="2dip"
        android:gravity="left|center_vertical" />

    <TextView
        android:id="@+id/away"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/girone"
        android:layout_marginLeft="2dip"
        android:layout_toRightOf="@+id/vs"
        android:gravity="right|center_vertical" />

    <TextView
        android:id="@+id/vs"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_below="@+id/girone"
        android:layout_centerHorizontal="true"
        android:background="#0000FF"
        android:gravity="center|center_vertical" />

</RelativeLayout>

If i write android:background="@drawable/logo" (to relativeLayout), the image logo.png is not scale... where I'm wrong?

Upvotes: 0

Views: 84

Answers (3)

Hamid Shatu
Hamid Shatu

Reputation: 9700

Add android:layout_height attribute to RelativeLayout xml as below...

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF" >

Update:

The XML layout which working perfectly...

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

    <TextView
        android:id="@+id/girone"
        style="@style/NomeSquadra"
        android:layout_width="fill_parent"
        android:layout_height="20dip" />

    <TextView
        android:id="@+id/home"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/girone"
        android:layout_marginLeft="2dip"
        android:gravity="left|center_vertical" />

    <TextView
        android:id="@+id/away"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/girone"
        android:layout_marginLeft="2dip"
        android:layout_toRightOf="@+id/vs"
        android:gravity="right|center_vertical" />

    <TextView
        android:id="@+id/vs"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_below="@+id/girone"
        android:layout_centerHorizontal="true"
        android:background="#0000FF"
        android:gravity="center|center_vertical" />

</RelativeLayout>

Upvotes: 0

Arvind Kanjariya
Arvind Kanjariya

Reputation: 2097

Try this

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

Upvotes: 1

Bhanu Sharma
Bhanu Sharma

Reputation: 5145

add height to the parent of this layout

 android:layout_height="fill_parent"

Upvotes: 0

Related Questions