Reputation: 1423
I got a custom dialog contains a checkBox. When I check the CheckBox, new view is created and added into Dialog. If I unchecked the CheckBox, it will make the view added gone and changes it back to previous view.
Here's it looks. Pictures on the left hand side is before check and left hand side is after checked.
As the dialog is checked, dialog layout will becomes bigger as pictures above.
My question is how to make dialog layout becomes bigger gradually instead of instantly. Something like animation that make the layout expand itself gradually.
This is my work so far.
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);
}
}
}
}
}
Upvotes: 1
Views: 154
Reputation: 22537
It is possible to animate a Dialog.
Please refer to this tutorial.
Sorry it is in japanese. And since I can read japanese I assume you can read japanese.
Upvotes: 1