Rohitesh
Rohitesh

Reputation: 987

Custom background color for RelativeLayout in Android is not working

I am facing a problem where using custom background color for RelativeLayout, is not working. The problem does not occur when I use a primary color (like RED). Any pointers will be appreciated.

I am pasting my view details here. It may not make sense as the map is not visible with this. But please ignore that bit. My concern is the background color.

What works :

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:keepScreenOn="true" >

    <com.google.android.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="@string/map_key"/>

    <RelativeLayout
        android:id="@+id/friendListBackground"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FF0000">
        <Button
            android:id="@+id/showAttendeesButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:drawableTop="@drawable/show_attendees_button" />
    </RelativeLayout>
</RelativeLayout>

What works

What doesn't work :

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:keepScreenOn="true" >

    <com.google.android.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="@string/map_key"/>

    <RelativeLayout
        android:id="@+id/friendListBackground"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#F0F3F6">
        <Button
            android:id="@+id/showAttendeesButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:drawableTop="@drawable/show_attendees_button" />
    </RelativeLayout>
</RelativeLayout>

What doesn't work

Any pointers on this would be very appreciated!

Upvotes: 0

Views: 1496

Answers (1)

AlexR
AlexR

Reputation: 43

As others mentioned, the second bit of code works perfectly fine.

The color works as it should

Upvotes: 1

Related Questions