How to make better custom dialogs?


Zoe

I am creating a game and I use a lot of dialogs in it. Dialogs make up the main menu with simpler settings, and then make up the entire activity for it. The dialogs, although they have a grey outline, are really annoying, and when going from one dialog to another, it shrinks and explodes, one disappears and the other disappears.

How can I remove the outline and make the transition smoother? If dialogs are not available, what are the options? I'm using a custom layout connected to a Java class that extends Dialog

edit

Java:

public class MenuDialog extends Dialog implements View.OnClickListener {
    Context con;
    Clicker c;
    public MenuDialog(Context c, Clicker game) {
        super(c);
        this.con = c;
        this.c = game;
        Window window = this.getWindow();
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        show();
    }


    Button stat, gem, cash, shop, powerup, settings;

    @Override
    protected void onCreate(Bundle sis){
        super.onCreate(sis);
        setContentView(R.layout.menu);
        setButtons();

    }

    private void setButtons(){
        stat = (Button) findViewById(R.id.bStats);
        gem = (Button) findViewById(R.id.bGems);

        gem.setOnClickListener(this);
        stat.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bStats:
                StatDialog sd = new StatDialog(con,c);
                sd.show();
                break;
            case R.id.bGems:
                IAPDialog iapd = new IAPDialog(con, c);
                iapd.show();
                break;
            //other buttons

        }
        dismiss();
    }

}

XML:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="visible"
    android:id="@+id/relativeLayout"
    android:gravity="center_horizontal"
    android:background="@drawable/phone_like_bc"
    android:orientation="horizontal">


    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:id="@+id/linearLayout5"

        android:layout_marginTop="51dp">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/bStats"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/bGems"
            android:background="@drawable/stat_button"
            android:layout_toStartOf="@+id/bGems" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="@string/stats"
            android:id="@+id/textView17"
            android:layout_below="@+id/bStats"
            android:layout_alignLeft="@+id/bStats"
            android:layout_alignStart="@+id/bStats" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:id="@+id/bShop"
            android:background="@drawable/shop"
            android:layout_below="@+id/textView17" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="@string/shop"
            android:textAlignment="center"
            android:id="@+id/textView18"
            android:layout_alignTop="@+id/textView16"
            android:layout_alignLeft="@+id/bShop"
            android:layout_alignStart="@+id/bShop" />
    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:id="@+id/linearLayout"
        android:layout_marginTop="51dp"
        >

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="@drawable/gem"
            android:id="@+id/bGems"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/linearLayout5"
            android:layout_toEndOf="@+id/linearLayout5" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="@string/gems"
            android:id="@+id/textView15"
            android:layout_alignBaseline="@+id/textView20"
            android:layout_alignBottom="@+id/textView20"
            android:layout_toLeftOf="@+id/bPowerUp"
            android:layout_toStartOf="@+id/bPowerUp"
            android:layout_gravity="center_horizontal" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:id="@+id/bPowerUp"
            android:background="@drawable/lightning"
            android:layout_alignTop="@+id/linearLayout"
            android:layout_toLeftOf="@+id/bSettings"
            android:layout_toStartOf="@+id/bSettings" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="@string/powerups"
            android:id="@+id/textView16"
            android:layout_alignBaseline="@+id/bSettings"
            android:layout_alignBottom="@+id/bSettings"
            android:layout_toLeftOf="@+id/bSettings"
            android:layout_toStartOf="@+id/bSettings" />
    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="51dp"
        android:gravity="center">

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:id="@+id/bCash"
            android:background="@drawable/cash"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:text=" " />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="@string/cash"
            android:id="@+id/textView19"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_gravity="center_horizontal" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:id="@+id/bSettings"
            android:background="@drawable/settings"
            android:layout_below="@+id/bCash"
            android:layout_alignLeft="@+id/bCash"
            android:layout_alignStart="@+id/bCash" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="@string/settings"
            android:id="@+id/textView20"
            android:layout_alignBottom="@+id/bCash"
            android:layout_alignLeft="@+id/textView19"
            android:layout_alignStart="@+id/textView19" />
    </LinearLayout>
</LinearLayout>

There are also two dialog classes, XML and Java. I added these two to show that I already know how to add the class, but I need to know how to remove the outline of the dialog, and I need to know how to make the transition between the two dialogs smoother. They also have the same background.

Alvaro

Instead of Dialogs, you can use DialogFragments, they can be used as Fragments, and you can customize them. Learn more about Dialog Fragment usage at https://developer.android.com/reference/android/app/DialogFragment.html .

If you don't like the Android documentation, there are plenty of tutorials for creating your own DialogFragments in Google.

Related


How to make this custom directive better?

dreamer I am trying to implement a custom directive for a counter widget . I've been able to implement it, but there are a lot of things I need some inspiration for. Can this instruction be written in a better way? How to use (isolate scope) scope:better ? Do

How to make this custom directive better?

dreamer I am trying to implement a custom directive for a counter widget . I've been able to implement it, but there are a lot of things I need some inspiration for. Can this instruction be written in a better way? How to use (isolate scope) scope:better ? Do

How to make this custom directive better?

dreamer I am trying to implement a custom directive for a counter widget . I've been able to implement it, but there are a lot of things I need some inspiration for. Can this instruction be written in a better way? How to use (isolate scope) scope:better ? Do

How to make this custom directive better?

dreamer I am trying to implement a custom directive for a counter widget . I've been able to implement it, but there are a lot of things I need some inspiration for. Can this instruction be written in a better way? How to use (isolate scope) scope:better ? Do

How to make this custom directive better?

dreamer I am trying to implement a custom directive for a counter widget . I've been able to implement it, but there are a lot of things I need some inspiration for. Can this instruction be written in a better way? How to use (isolate scope) scope:better ? Do

How to migrate custom buttons and dialogs to TinyMCE 5

Gypsy I have a 3rd party Bootstrap plugin (probably EOL) that adds buttons to the toolbar which in turn open a dialog where Bootstrap elements can be selected to add to the content. It uses the following code: var insertBtn = tinymce.ui.Factory.create({ ty

How to create custom expandable dialogs with ControlsFX

Anton Antonov I want to create the same dialog that I create when using Dialogs.showException(), but instead of showing the stacktrace, I want to show my custom preformatted text. The functionality I want is the "details" button behavior. What I want is: But n

How to migrate custom buttons and dialogs to TinyMCE 5

Gypsy I have a 3rd party Bootstrap plugin (probably EOL) that adds buttons to the toolbar which in turn open a dialog where Bootstrap elements can be selected to add to the content. It uses the following code: var insertBtn = tinymce.ui.Factory.create({ ty

How to create custom expandable dialogs with ControlsFX

Anton Antonov I want to create the same dialog that I create when using Dialogs.showException(), but instead of showing the stacktrace, I want to show my custom preformatted text. The functionality I want is the "details" button behavior. What I want is: But n

How to Make Internet Explorer ActiveX Dialogs Visible

Jon I have an ActiveX control written in C# that uses WIA to operate a scanner in the browser. Everything works fine, except the WIA CommonDialog pops up under the browser window. How can I make it appear at the top of the browser? wiaDialog = new WIA.CommonDi

How to make reusable components for dialogs or modals?

Anaya Dream I want to make a reusable component for a dialog that has a yes or no button at the bottom, where "yes" would be the type of button to submit. Because I want to create a dialog to ask the user if they are sure about the entered information before s

How to Make Internet Explorer ActiveX Dialogs Visible

Jon I have an ActiveX control written in C# that uses WIA to operate a scanner in the browser. Everything works fine, except the WIA CommonDialog pops up under the browser window. How can I make it appear at the top of the browser? wiaDialog = new WIA.CommonDi

How to Make Internet Explorer ActiveX Dialogs Visible

Jon I have an ActiveX control written in C# that uses WIA to operate a scanner in the browser. Everything works fine, except the WIA CommonDialog pops up under the browser window. How can I make it appear at the top of the browser? wiaDialog = new WIA.CommonDi

How to make it better in Kotlin?

Artur A: How to make it better in Kotlin, should I use! = null or is there a better way var uriBuilder = UriBuilder() if (query != null) { uriBuilder = uriBuilder.query(query) } Meier: I think these ifstatements are easy to understand and understandable,

How to make better lines?

Chai_Latte So I'm making a paint application in C#, and it works like this: when the user clicks on the paint panel, it marks a point, then when the user moves the mouse to a new location, the mouse draws a line down. I'm learning C# so it's pretty basic. Ever

how to make this filter better

dreamer I want to take the class selected ng-repeatfrom the selectinput . For this I use custom filter. I'm hardcoding all values whenever arrayFilterundefined or arrayFilterempty arrayFilter, otherwise arrayFiltercontaining the value chosen from the selectinp

How to make it better in Kotlin?

Artur A: How to make it better in Kotlin, should I use! = null or is there a better way var uriBuilder = UriBuilder() if (query != null) { uriBuilder = uriBuilder.query(query) } Meier: I think these ifstatements are easy to understand and understandable,

How to make it better in Kotlin?

Arthur I would like to know this code, instead of splitting the convert(), can I be anonymous in the map {} fun <A, B> LiveData<A>.map(function: (A) -> B): LiveData<B> = Transformations.map(this, function) fun loadSettings() { configLiveData.map { configF

How to make better lines?

Chai_Latte So I'm making a paint application in C#, and it works like this: when the user clicks on the paint panel, it marks a point, then when the user moves the mouse to a new location, the mouse draws a line down. I'm learning C# so it's pretty basic. Ever

How to make better lines?

Chai_Latte So I'm making a paint application in C#, and it works like this: when the user clicks on the paint panel, it marks a point, then when the user moves the mouse to a new location, the mouse draws a line down. I'm learning C# so it's pretty basic. Ever

How to make validation better?

Ethan I'm doing phone verification for 2 brands, and both verifications mean pretty much the same thing, just a different number of digits. if (!MobileFormat(num, brand,currency)) { if (brand.Equals(Brand.LED.ToString()))

how to make this filter better

dreamer I want to take the class selected ng-repeatfrom the selectinput . For this I use custom filter. I'm hardcoding all values whenever arrayFilterundefined or arrayFilterempty arrayFilter, otherwise arrayFiltercontaining the value chosen from the selectinp

how to make this filter better

dreamer I want to ng-repeatrun the class selected from the selectinput . For this I use custom filter. I'm hardcoding all values whenever arrayFilterundefined or arrayFilterempty arrayFilter, otherwise arrayFiltercontaining the value chosen from the selectinpu

How to make it better in Kotlin?

Artur A: How to make it better in Kotlin, should I use! = null or is there a better way var uriBuilder = UriBuilder() if (query != null) { uriBuilder = uriBuilder.query(query) } Meier: I think these ifstatements are easy to understand and understandable,

How to make it better in Kotlin?

Artur A: How to make it better in Kotlin, should I use! = null or is there a better way var uriBuilder = UriBuilder() if (query != null) { uriBuilder = uriBuilder.query(query) } Meier: I think these ifstatements are easy to understand and understandable,

How to make better lines?

Chai_Latte So I'm making a paint application in C#, and it works like this: when the user clicks on the paint panel, it marks a point, then when the user moves the mouse to a new location, the mouse draws a line down. I'm learning C# so it's pretty basic. Ever

How to make better lines?

Chai_Latte So I'm making a paint application in C#, and it works like this: when the user clicks on the paint panel, it marks a point, then when the user moves the mouse to a new location, the mouse draws a line down. I'm learning C# so it's pretty basic. Ever

How to make validation better?

Ethan I'm doing phone verification for 2 brands, and both verifications mean pretty much the same thing, just a different number of digits. if (!MobileFormat(num, brand,currency)) { if (brand.Equals(Brand.LED.ToString()))

How to make validation better?

Ethan I'm doing phone verification for 2 brands, and both verifications mean pretty much the same thing, just a different number of digits. if (!MobileFormat(num, brand,currency)) { if (brand.Equals(Brand.LED.ToString()))