-3

I am trying to remove background from popup dialog, but it's showing white color behind the cardview

background = @null is not working

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lnrMstr"
android:orientation="vertical"
android:background="#0D000000">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_main"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="@dimen/_5sdp"
        app:cardElevation="@dimen/_5sdp"
        app:cardUseCompatPadding="true"
        android:layout_margin="@dimen/_2sdp"
        android:layout_gravity="center_horizontal">

 </android.support.v7.widget.CardView>

</LinearLayout>
Umeshkumar D.
  • 412
  • 4
  • 18
Keyur Patel
  • 172
  • 1
  • 2
  • 12
  • 2
    `#0D000000` should be either `#00000000`, or `@android:color/transparent`. Also, use `dp` to set the CardView margins. – Susmit Agrawal Aug 20 '18 at 12:48
  • If you have a white bg color on `#0D000000` then this bg color might be related to a parent of the `LinearLayout`, since `#000000` is black and not white. – Abbas Aug 20 '18 at 12:57
  • background #00000000 i\or transparent is not working for me – Keyur Patel Aug 21 '18 at 03:58

2 Answers2

3

you don't need to remove that color from background just set dialog window background as transparent.

add in code:

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

reference :more details

Vishal Thakkar
  • 2,117
  • 2
  • 16
  • 33
  • i would suggest first proper search you will get most of answer. if still you get problem then post with efforts. – Vishal Thakkar Aug 21 '18 at 04:50
  • @VishalThakkar What is different in you answer and this [link](https://stackoverflow.com/a/10795234/5995648) answer should different, otherwise juts put as comment. – Arbaz.in Aug 21 '18 at 10:21
  • @Arbaz.in check comment i was already commented first. – Vishal Thakkar Aug 21 '18 at 10:40
  • @vishal . Yes i saw that and its not about the who comment first but if you're refering any other people answer .you should also attached the link along with the solution as it goes to whom so ever is concerned. – Arbaz.in Aug 21 '18 at 10:53
0

try this by edit the color #0D000000 to #00000000

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lnrMstr"
android:orientation="vertical"
android:background="#00000000">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_main"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="@dimen/_5sdp"
        app:cardElevation="@dimen/_5sdp"
        app:cardUseCompatPadding="true"
        android:layout_margin="@dimen/_2sdp"
        android:layout_gravity="center_horizontal">
 </android.support.v7.widget.CardView>

</LinearLayout>
Mohammad Rbabah
  • 456
  • 2
  • 10