-
Notifications
You must be signed in to change notification settings - Fork 1
Dialog Fragment
Dialogs in Android sucks, there is no nicer way to describe them. If you need a standard selection dialog or a simple alert dialog, then it's easy enough to work with. But if you want a custom dialog with custom layout it can be a pain. Especially when it comes to controlling the height and width.
UtilsLib comes packed with a custom DialogFragment that makes this much easier, while at the same time includes the regular tools from the library like the message system for easy communication between Fragments and their Activity.
To make it as easy as possible, MsgFragmentDialog includes two new alternatives to onCreateView namely onCreateWindowView and onCreateDialogView. The differences between those two methods is that onCreateDialogView has larger margins and has a smaller default max width and height. One is to display smaller pieces of content like simple selection, information etc. while the other is for larger content. The default max width and height can be changes using setMaxSize(float maxHeight, float maxWidth) in dip.
The default max width and height as well as the Window and Dialog margins has been customized for all screen sizes. The dialog version will by default never exceed 360x540 dip and the window version has been set to 560x920 dip`.
public class MyDialog extends MsgFragmentDialog {
@Override
public View onCreateWindowView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.my_dialog, container, false);
}
}