How to make better custom dialogs?
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.
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.