or specify a percentage of the screen size?
You can't, if you could it would be in the README.
Because I've struggled with the same question I would like to provide a possible solution or workaround for this.
You can do this by extending the MaterialDialog-Class and then use the getWindow().setAttributes(WindowManager.LayoutParams a)-Method.
For example in my case I needed a simple, small Loading-Dialog which locks the screen and just show a rotating intermediate progress inside without any text.
Therefor I extended the MaterialDialog and called the Super-Constructor with the Progress-Definition. Then I altered the width in the LayoutParams of the Window and set the new LayoutParams. Keep in mind, that you have to define the width and height in pixels and so you have to convert your values.
public class LightLoader extends MaterialDialog {
public LightLoader(Context context){
super(new MaterialDialog.Builder(context).progress(true, 0));
ViewGroup.LayoutParams params = getWindow().getAttributes();
params.width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
128,
context.getResources().getDisplayMetrics());
getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
setCancelable(false);
this.show();
}
}
By the way: Great library and thanks for your work!
Most helpful comment
Because I've struggled with the same question I would like to provide a possible solution or workaround for this.
You can do this by extending the
MaterialDialog-Class and then use thegetWindow().setAttributes(WindowManager.LayoutParams a)-Method.For example in my case I needed a simple, small Loading-Dialog which locks the screen and just show a rotating intermediate progress inside without any text.
Therefor I extended the
MaterialDialogand called the Super-Constructor with the Progress-Definition. Then I altered the width in theLayoutParamsof theWindowand set the newLayoutParams. Keep in mind, that you have to define the width and height in pixels and so you have to convert your values.By the way: Great library and thanks for your work!