-2

I have designed a custom dialog in adobe xd but now I want to initiate it as in xml and in java . So what should I do now to create a custom dialog. I know hot to build a dialog box but not a custom dialog . Please help.

This is my designed dialog

Suraj Giri
  • 202
  • 1
  • 13

1 Answers1

0

You can create a custom dialog extending DialogFragment and you can have something like this.

public class myCustomDialog extends DialogFragment {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setStyle(android.support.v4.app.DialogFragment.STYLE_NO_TITLE, R.style.dialogsimple);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.custom_dialog, container, false);
    v.setBackgroundResource(android.R.color.transparent);

}

And then in your style you can use this

<style name="dialogsimple" parent="Base.V11.Theme.AppCompat.Light.Dialog">
    <item name="android:background">@drawable/round_corners_view</item>
    <item name="android:textStyle">normal</item>
    <item name="android:backgroundDimEnabled">true</item>
</style>

And your layout can by the xml of your design, I believe this is the fastest way to make what you need.

Dinorah Tovar
  • 488
  • 2
  • 15