Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw java.lang.IllegalArgumentException: width and height must be > 0 #9

Closed
suleymanccelik opened this issue Jul 9, 2015 · 3 comments
Assignees
Labels
Milestone

Comments

@suleymanccelik
Copy link

I am using material dialogs ( https://github.com/afollestad/material-dialogs ) on my dialog fragment. In my dialog fragment onCreateDialog() method :

MaterialDialog.Builder dialogBuilder = new MaterialDialog.Builder(getActivity())
.content(R.string.logout_content)
.positiveText(R.string.logout_positive)
.negativeText(R.string.logout_negative)
.callback(new MaterialDialog.ButtonCallback() {
@OverRide
public void onPositive(MaterialDialog dialog) {
}
@OverRide
public void onNegative(MaterialDialog dialog) {
}
});
MaterialDialog dialog = dialogBuilder.build();
dialog.getWindow().getAttributes().height = WindowManager.LayoutParams.WRAP_CONTENT;
dialog.getWindow().getAttributes().width = WindowManager.LayoutParams.WRAP_CONTENT;
dialog.show();
return dialog;

But I faced an error. Error log :

Caused by: java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:933)
at android.graphics.Bitmap.createBitmap(Bitmap.java:912)
at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
at com.ms.square.android.etsyblur.Util.drawViewToBitmap(Util.java:31)
at com.ms.square.android.etsyblur.BlurDialogFragmentHelper.onActivityCreated(BlurDialogFragmentHelper.java:94)
at fragment.LogoutFragment.onActivityCreated(LogoutFragment.java:81)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1797)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:979)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1120)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1929)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1234)
at android.app.Activity.performStart(Activity.java:6412)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2777)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2879)
at android.app.ActivityThread.access$900(ActivityThread.java:182)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6141)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

@MustafaFerhan
Copy link

is there any solution?

MateuszMlodawski added a commit to MateuszMlodawski/EtsyBlur that referenced this issue Aug 19, 2015
MateuszMlodawski added a commit to MateuszMlodawski/EtsyBlur that referenced this issue Aug 19, 2015
@MateuszMlodawski
Copy link

For me adding OnGlobalLayoutListener solved the problem.
MateuszMlodawski@89e8c08

@Manabu-GT Manabu-GT added the bug label Aug 20, 2015
@Manabu-GT Manabu-GT modified the milestones: v0.1.1, v0.1.2 Aug 20, 2015
@Manabu-GT Manabu-GT self-assigned this Aug 20, 2015
Manabu-GT added a commit that referenced this issue Aug 23, 2015
Manabu-GT added a commit that referenced this issue Aug 23, 2015
fix: zero width/height exception #9
@Manabu-GT
Copy link
Owner

The fix (getting width/height after the layout pass to avoid 0 width/height) is in v0.1.2.
Please let me know if you still experience the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants