我正在尝试为DialogFragment设置进入和退出转换,这似乎很直接.以下是我的DrinkDetailActivity中创建对话框的代码:
fab.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
//create and display the dialog
DialogFragment orderFragment = new OrderDrinkDialogFragment();
//set the slide transition for the fragment
Transition dialSlide = new Slide();
dialSlide.setDuration(300);
orderFragment.setEnterTransition(dialSlide);
orderFragment.setExitTransition(dialSlide);
orderFragment.show(getFragmentManager(), "order");
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的OrderDrinkDialogFragment类的代码:
public class OrderDrinkDialogFragment extends DialogFragment
{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
AlertDialog.Builder builder = new AlertDialog.Builder(DrinkDetailActivity.activity);
//set up the Linear Layout of the dialog
LinearLayout layout = new LinearLayout(DrinkDetailActivity.activity);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setLayoutParams(params);
//set up the …Run Code Online (Sandbox Code Playgroud) 我的应用程序有问题.我像这样使用全屏选项:
public void setFullscreen() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Run Code Online (Sandbox Code Playgroud)
但是,稍后在游戏过程中,当我显示AlertDialog的帮助/信息时,状态栏会在几分之一秒内恢复并再次消失,从而产生闪烁或跳跃效果.此外,Dialog本身并不是应该居中,几乎就像它认为有一个状态栏一样.
以下是我显示对话框的方法:
protected Dialog onCreateDialog(int id) {
TextView tv;
switch (id) {
case MENU_HELP:
tv = new TextView(this);
tv.setText(R.strings.help_msg);
return new AlertDialog.Builder(BlackJackView.this)
.setIcon(android.R.drawable.ic_menu_help)
.setTitle("How-To")
.setView(tv)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
}
})
.create();
}
………
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
有谁知道可能导致这种情况出现/消失的原因是什么?如何让它停止这种跳跃行为?
感谢你的帮助.