Closed suleymanccelik closed 9 years ago
is there any solution?
For me adding OnGlobalLayoutListener solved the problem. https://github.com/MateuszMlodawski/EtsyBlur/commit/89e8c08d250edd8c1d398d0b74e0f329572beb42
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.
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)