Omar HossamEldin
Omar HossamEldin

Reputation: 3111

Can't remove the black background of a relative layout contains a listView

I'm implementing a custom Dialog which inflates a RelativeLayout xml file

The xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="match_parent"
android:gravity="center_horizontal" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY"
    android:src="@drawable/common_image_list_panel_transparent" />

<ListView
    android:id="@+id/teamListView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="15dp"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"
    android:layout_marginTop="65dp"
    android:cacheColorHint="#00000000"
    android:divider="@drawable/common_team_list_view_divider"
    android:dividerHeight="1dp"
    android:fadingEdge="none"
    android:scaleType="centerCrop" >
</ListView>

<ImageButton
    android:id="@+id/cancelTeamDialogButton"
    android:layout_width="25dp"
    android:layout_height="25dp"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="14dp"
    android:layout_marginTop="15dp"
    android:background="@drawable/create_incident_screen_map_overlay_image_close"
    android:gravity="center"
    android:scaleType="fitXY" />

<TextView
    android:id="@+id/listTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="15dp"
    android:gravity="center_horizontal|fill_horizontal|center_vertical|fill_vertical"
    android:textSize="22sp" />

</RelativeLayout>

I tried to change the background color of the RelativeLayout and the ListView but nothing happens. I always get this enter image description here

I've already removed the background border of the dialog

dialog.getWindow().setBackgroundDrawable(
    new ColorDrawable(getResources().getColor(R.color.transparent)));

The background image is a png with a frame and the rest is transparent and I positioned the ListView inside the frame. what i want is removing the black color from the background which present in side the frame and outside around the rounded corners of the frame.

Upvotes: 0

Views: 2081

Answers (3)

Omar HossamEldin
Omar HossamEldin

Reputation: 3111

I was using AlertDialog instead of Dialog

Upvotes: 0

Daniel Conde Marin
Daniel Conde Marin

Reputation: 7742

Add this attributes to the ListView:

<android:listSelector = "@android:color/transparent"/>
<android:drawSelectorOnTop = "true"/>

Edit: With the previous attributes added to the ListView, then you can put a white background to the Relative Layout, by adding this to it:

<android:background = "@android:color/white"/>

Upvotes: 0

mihirjoshi
mihirjoshi

Reputation: 12201

android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"

These two lines will do the trick.

Upvotes: 2

Related Questions