8

I am applying a drawable background in our xml layout but it also contains border how to remove it ?

When i put the corners then it apply the corner but it not apply the corner on whole layout (means not content goes outside the border area).

custom dialog box image

This is my drawable file

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

<solid
    android:color="#fff">

</solid>

<stroke
    android:width="2dp"
    android:color="@color/block_button_bg">

</stroke>

<corners
    android:radius="10dp">

</corners>


</shape>

and this my xml layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:background="@drawable/custom_dialog_bg">

<TextView
    android:id="@+id/txtDiaTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/app_dialog_title"
    android:textColor="@color/black"
    android:textStyle="bold"
    android:gravity="center"
    android:padding="8dp"
    android:textAppearance="@android:style/TextAppearance.Medium"/>

<TextView
    android:id="@+id/txtDiaMsg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:padding="6dp"
    android:layout_gravity="center"
    android:layout_marginBottom="10dp"
    android:text="@string/app_dialog_desc"
    android:textColor="@color/black"
    android:textSize="12sp"/>

<View
    android:layout_width="match_parent"
    android:layout_height="1dip"
    android:background="@color/alarm_color"
    />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/yes"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        android:text="@string/yes"
        android:textColor="#0C76EE"
        android:textStyle="bold"
        android:padding="5dp"
        android:clickable="true"
        android:layout_margin="5dp" />

    <View
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:background="@color/alarm_color"
        />

    <TextView
        android:id="@+id/no"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        android:text="@string/no"
        android:textColor="#0C76EE"
        android:textStyle="bold"
        android:padding="5dp"
        android:clickable="true"
        android:layout_margin="5dp" />

    </LinearLayout>

</LinearLayout>

Any idea?

Ujjwal Jha
  • 115
  • 1
  • 8

2 Answers2

8

you do every thing good. but you must use transparent theme for your dialog, or set background window of dialog transparent. Like this:

dialog.getWindow().setBackgroundDrawable(new       ColorDrawable(android.graphics.Color.TRANSPARENT));

or use this link.

Community
  • 1
  • 1
Haniyeh Khaksar
  • 774
  • 4
  • 20
0

Can you please try below one ?

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

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

    <corners android:radius="10dip" />

    <stroke
        android:width="1dp"
        android:color="@android:color/white" />

</shape>

Hope this will help you.

Hiren Patel
  • 52,124
  • 21
  • 173
  • 151