Search code examples
javaandroidtransparentdialogfragment

Transparent DialogFragment over Activity


I've tried all the solutions here and it seems that non of them works for me. The following code was working fine on Android Kitkat but in Oreo 8.1 it always has that ugly black block under the dialogfragment, no matter what style I try

The code to invoke the dialog:

FragmentManager pfm = getFragmentManager();
NewPointMapPopup pointSaveDialog = new NewPointMapPopup();
Bundle args = new Bundle();
args.putParcelable("newPoint", tapLoc);
args.putInt("screenX",Math.round(canvasX));
args.putInt("screenY",Math.round(canvasY));
args.putInt("screenHeight",canvasHeight);
pointSaveDialog.setArguments(args);
pointSaveDialog.show(pfm, "");

The code onCreateView:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.new_point_map_popup, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

and the layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/popup_main_layout"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/map_popup_bg"
    android:padding="1dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:padding="10dp"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="10dp"
                    android:gravity="right"
                    android:orientation="vertical">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/foretrexBlue"
                        android:text="Latitude:"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/foretrexBlue"
                        android:text="Longitude:"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/foretrexBlue"
                        android:text="Distance:"/>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">
                    <TextView
                        android:id="@+id/new_point_lat"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/foretrexBlue"
                        android:text="43.1231233"/>
                    <TextView
                        android:id="@+id/new_point_lon"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/foretrexBlue"
                        android:text="25.55656666"/>
                    <TextView
                        android:id="@+id/new_point_distance"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/foretrexBlue"
                        android:text="250 m"/>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:weightSum="2"
        android:orientation="horizontal">
        <Button
            style="@style/MFButton"
            android:id="@+id/new_point_close"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:visibility="visible"
            android:layout_weight="1"
            android:text="Close"/>
        <Button
            style="@style/MFButton"
            android:id="@+id/new_point_save"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Save"/>
    </LinearLayout>
</LinearLayout>

Solution

  • It was obviously Android Oreo 8.1 bug. After the update from 5th Oct 2018, the problem is solved.