I used youtuber Coding in Flow's method to create a custom dialog. I've been trying all day to make the dialog's background transparent. I've used every single method I've found online. Non worked.
Here's how it goes:
First here's the Dialog layout layout_dialog.xml :
<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" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:background="@drawable/dialog_background"> <!-- The contents of the Dialog go here --> </RelativeLayout> <ImageView android:id="@+id/iconImageView2" android:layout_width="100dp" android:layout_height="100dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="0dp" android:background="?attr/actionBarItemBackground" android:scaleType="fitCenter" app:srcCompat="@android:mipmap/sym_def_app_icon" /> </RelativeLayout>Here's the Dialog class:
public class DialogBrightness extends AppCompatDialogFragment { //declare whatever variables here @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.layout_dialog, null); builder.setView(view) .setTitle("Login") .setNegativeButton("cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }) .setPositiveButton("ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //get whatever values listener.apply(//values); } }); //findViewById for your dialog contents here return builder.create(); } public interface DialogBrightnessListener { void apply(//values); } }And here's the Dialog being called from the Main activity:
DialogBrightness dialogBrightness = new DialogBrightness(); dialogBrightness.show(getSupportFragmentManager(), "Brightness Dialog");
This is how the Dialog appears:
I'm trying to make the top white part invisible. Nothing works!

