java如何制作更好的自定义对话框?
我正在制作一个游戏,在其中我使用了很多对话。对话框以更简单的设置构成主菜单,然后构成整个活动。然而,这些对话有一个灰色的轮廓,这真的很烦人。此外,当从一个对话转到另一个对话时,当一个消失,另一个重新出现时,它会缩小并爆炸
如何删除轮廓,使过渡更加平滑?如果无法使用对话框,可以选择什么?我正在使用与扩展Dialog的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:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:visibility="visible"
安卓:id="@+id/relativeLayout"
安卓:gravity="center_horizontal"
安卓:background="@drawable/phone_like_bc"
安卓:orientation="horizontal">
<LinearLayout
安卓:orientation="vertical"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:gravity="center"
安卓:id="@+id/linearLayout5"
安卓:layout_marginTop="51dp">
<Button
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:id="@+id/bStats"
安卓:layout_alignParentTop="true"
安卓:layout_toLeftOf="@+id/bGems"
安卓:background="@drawable/stat_button"
安卓:layout_toStartOf="@+id/bGems" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textAppearance="?安卓:attr/textAppearanceMedium"
安卓:text="@string/stats"
安卓:id="@+id/textView17"
安卓:layout_below="@+id/bStats"
安卓:layout_alignLeft="@+id/bStats"
安卓:layout_alignStart="@+id/bStats" />
<Button
安卓:layout_width="100dp"
安卓:layout_height="100dp"
安卓:id="@+id/bShop"
安卓:background="@drawable/shop"
安卓:layout_below="@+id/textView17" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textAppearance="?安卓:attr/textAppearanceMedium"
安卓:text="@string/shop"
安卓:textAlignment="center"
安卓:id="@+id/textView18"
安卓:layout_alignTop="@+id/textView16"
安卓:layout_alignLeft="@+id/bShop"
安卓:layout_alignStart="@+id/bShop" />
</LinearLayout>
<LinearLayout
安卓:orientation="vertical"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:gravity="center"
安卓:id="@+id/linearLayout"
安卓:layout_marginTop="51dp"
>
<Button
安卓:layout_width="100dp"
安卓:layout_height="100dp"
安卓:background="@drawable/gem"
安卓:id="@+id/bGems"
安卓:layout_centerVertical="true"
安卓:layout_toRightOf="@+id/linearLayout5"
安卓:layout_toEndOf="@+id/linearLayout5" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textAppearance="?安卓:attr/textAppearanceMedium"
安卓:text="@string/gems"
安卓:id="@+id/textView15"
安卓:layout_alignBaseline="@+id/textView20"
安卓:layout_alignBottom="@+id/textView20"
安卓:layout_toLeftOf="@+id/bPowerUp"
安卓:layout_toStartOf="@+id/bPowerUp"
安卓:layout_gravity="center_horizontal" />
<Button
安卓:layout_width="100dp"
安卓:layout_height="100dp"
安卓:id="@+id/bPowerUp"
安卓:background="@drawable/lightning"
安卓:layout_alignTop="@+id/linearLayout"
安卓:layout_toLeftOf="@+id/bSettings"
安卓:layout_toStartOf="@+id/bSettings" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textAppearance="?安卓:attr/textAppearanceMedium"
安卓:text="@string/powerups"
安卓:id="@+id/textView16"
安卓:layout_alignBaseline="@+id/bSettings"
安卓:layout_alignBottom="@+id/bSettings"
安卓:layout_toLeftOf="@+id/bSettings"
安卓:layout_toStartOf="@+id/bSettings" />
</LinearLayout>
<LinearLayout
安卓:orientation="vertical"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="51dp"
安卓:gravity="center">
<Button
安卓:layout_width="100dp"
安卓:layout_height="100dp"
安卓:id="@+id/bCash"
安卓:background="@drawable/cash"
安卓:layout_alignParentTop="true"
安卓:layout_alignParentRight="true"
安卓:layout_alignParentEnd="true"
安卓:text=" " />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textAppearance="?安卓:attr/textAppearanceMedium"
安卓:text="@string/cash"
安卓:id="@+id/textView19"
安卓:layout_alignParentTop="true"
安卓:layout_alignParentLeft="true"
安卓:layout_alignParentStart="true"
安卓:layout_gravity="center_horizontal" />
<Button
安卓:layout_width="100dp"
安卓:layout_height="100dp"
安卓:id="@+id/bSettings"
安卓:background="@drawable/settings"
安卓:layout_below="@+id/bCash"
安卓:layout_alignLeft="@+id/bCash"
安卓:layout_alignStart="@+id/bCash" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textAppearance="?安卓:attr/textAppearanceMedium"
安卓:text="@string/settings"
安卓:id="@+id/textView20"
安卓:layout_alignBottom="@+id/bCash"
安卓:layout_alignLeft="@+id/textView19"
安卓:layout_alignStart="@+id/textView19" />
</LinearLayout>
</LinearLayout>
还有另外两个对话框类XML和java。我添加这两个是为了表明我已经知道如何添加类,但我需要知道如何删除对话框的大纲,以及如何平滑两个对话框之间的过渡。他们也有同样的背景
共 (0) 个答案