0

I am trying to make a transparent background header for close button. The background header is working as expected, however the background layout can see the visible and button is also not clear.

Am trying to build like this below picture

https://ibb.co/CVgrzjq

My code is as follows:

Activity Code

final BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetMainStyle);
`dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
`dialog.show();

Layout Code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:background="@android:color/transparent"
    android:gravity="center|top"
    android:orientation="vertical">


    <ImageView
        android:id="@+id/img_close"
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_alignParentTop="true"
        android:layout_centerInParent="true"
        android:background="@android:color/transparent"
        android:clickable="true"
        android:forceDarkAllowed="false"
        android:paddingBottom="@dimen/dimen_8"
        android:src="@drawable/bottom_close"
        />


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="300dp"

        android:layout_below="@id/img_close"
        android:background="@drawable/rounded_dialog"
        app:background="@color/bkgcolor"
        android:orientation="vertical">

        <!-- All your required widgets here-->
    </RelativeLayout>
</RelativeLayout>
Zain
  • 37,492
  • 7
  • 60
  • 84
Arooshi
  • 91
  • 5

1 Answers1

0

Activity code

final BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.trans_bg_dialog);
`dialog.show();

Add this in your style.xml file

 <style name="trans_bg_dialog" parent="@style/Theme.AppCompat.Dialog">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
</style>