Android 如何使对话框逐渐变大而不是瞬间变大

Android 如何使对话框逐渐变大而不是瞬间变大,android,animation,android-animation,Android,Animation,Android Animation,我得到了一个包含复选框的自定义对话框。当我选中该复选框时,将创建新视图并将其添加到对话框中。如果我取消选中该复选框,它将使添加的视图消失,并将其更改回以前的视图 这是它的外观。左侧的图片在检查前,左侧的图片在检查后。 选中对话框后,对话框布局将变大,如上图所示 我的问题是如何使对话框布局逐渐变大,而不是立即变大。 类似动画的东西使布局逐渐扩展 这是我目前为止的工作 public class CreateRoomDialogFragment extends DialogFragment {

我得到了一个包含复选框的自定义对话框。当我选中该复选框时,将创建新视图并将其添加到对话框中。如果我取消选中该复选框,它将使添加的视图消失,并将其更改回以前的视图

这是它的外观。左侧的图片在检查前,左侧的图片在检查后。

选中对话框后,对话框布局将变大,如上图所示

我的问题是如何使对话框布局逐渐变大,而不是立即变大。 类似动画的东西使布局逐渐扩展

这是我目前为止的工作

public class CreateRoomDialogFragment extends DialogFragment {


    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the Builder class for convenient dialog construction
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        //Get layout inflater
        LayoutInflater inflater = getActivity().getLayoutInflater();

        //R.layout.add_player2 is the layout shows on dialog message
        view = inflater.inflate(R.layout.createroom_dialog_fragment, null);

        roomName = (EditText)view.findViewById(R.id.createroom_dialog_roomname);
        roomKey = (EditText)view.findViewById(R.id.createroom_dialog_key);
        keyLayout = (LinearLayout)view.findViewById(R.id.keyLayout);        
        checkBoxLayout1 = (RelativeLayout)view.findViewById(R.id.createroom_dialog_layout1);
        checkBoxLayout2 = (RelativeLayout)view.findViewById(R.id.createroom_dialog_layout2);

        // lock the room with key
        checkBox1 = (CheckBox)view.findViewById(R.id.createroom_dialog_checkbox1);

        // show the key
        checkBox2 = (CheckBox)view.findViewById(R.id.createroom_dialog_checkbox2);


        checkBox1.setOnCheckedChangeListener(new CreateRoomCheckBoxListener());
        checkBox2.setOnCheckedChangeListener(new CreateRoomCheckBoxListener());
    }   

    private class CreateRoomCheckBoxListener implements OnCheckedChangeListener{

        @Override
        public void onCheckedChanged(CompoundButton buttonView,
                boolean isChecked) {

            if(buttonView == checkBox1){
                // lock the room with key
                if(isChecked){

                    roomKey.setVisibility(View.VISIBLE);
                    checkBoxLayout2.setVisibility(View.VISIBLE);                    

                }else{

                    roomKey.setVisibility(View.GONE);
                    checkBoxLayout2.setVisibility(View.GONE);
                }

            }   
        }

    }


}

可以设置对话框的动画。
请参阅此项。

对不起,是日语的。既然我能读日语,我想你也能读日语。

可以制作对话动画。
请参阅此项。

对不起,是日语的。既然我能读日语,我想你也能读日语。

谢谢你的链接。你的假设是正确的,我懂日语:)谢谢你的链接。你的假设是正确的,我懂日语:)