Reputation: 415
i am designing a linear layout with rounded corner for custom dialog alert when it popups the white popup overlaps over black layout even without mentioning background as black which is shown with rounded in added image.i want to display popup with rounded corner with no black color part as mentioned in image,
can anybody help me please.
customDialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@null"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/rounded_corner"
android:orientation="vertical" >
<TextView
android:id="@+id/dialog_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="none"
android:gravity="center_vertical|center_horizontal"
android:maxLines="50"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:scrollHorizontally="false"
android:text="title"
android:textColor="@color/aa_text"
android:textSize="25dp" />
<TextView
android:id="@+id/dialog_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="none"
android:maxLines="50"
android:paddingBottom="10dp"
android:paddingLeft="40dp"
android:paddingTop="10dp"
android:scrollHorizontally="false"
android:text="message"
android:textColor="@color/black"
android:textSize="20dp" />
<ListView
android:id="@+id/dialog_lv_options"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:visibility="gone" />
<ImageView
android:id="@+id/popupBorder"
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="@color/background" />
<LinearLayout
android:id="@+id/dialog_ll_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<Button
android:id="@+id/dialog_positivebutton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/dialog_button_selector"
android:text="OK"
android:textColor="@color/background" />
<ImageView
android:id="@+id/btnBorder"
android:layout_width="1px"
android:layout_height="fill_parent"
android:background="@color/background" />
<Button
android:id="@+id/dialog_negativebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/dialog_button_selector"
android:text="Cancel"
android:textColor="@color/background" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
rounded_corner.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#eeeeee"/>
<stroke android:width="3dip" android:color="#eeeeee" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
Upvotes: 0
Views: 4331
Reputation: 17
Put this property on the LinearLayout tag or element:
android:background="@color/fui_transparent"
Upvotes: 0
Reputation: 1414
I used
android:elevation="0sp"
to remove the shadow. Works fine and you can still have a background set on the LinearLayout.
Upvotes: 0
Reputation: 488
If you use Dialog class, try this answer: https://stackoverflow.com/a/3114466/837714 Quote from there:
Create a custom style and place it in your values folder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YourCustomStyle" parent="android:Theme">
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
To set a style to an individual dialog you can use
Dialog dialog = new Dialog(context, R.style.YourCustomStyle);
UPDATE
Move up from comments:
I misunderstood the question. Actual solution is:
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
Upvotes: 1