gpt4 book ai didi

android - 如何使对话框逐渐变大而不是立即变大

转载 作者:行者123 更新时间:2023-11-30 03:38:36 25 4
gpt4 key购买 nike

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

这是它的外观。左边是检查前的照片,左边是检查后的照片。 enter image description here

勾选对话框后,对话框布局会变大,如上图。

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

这是我到目前为止的工作。

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);
}

}
}

}


}

最佳答案

可以为对话框设置动画。
请引用这个tutorial .
抱歉是日文的。因为我会读日语,所以我假设你会读日语。

关于android - 如何使对话框逐渐变大而不是立即变大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16209236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com