Thursday, 15 May 2014

android - How to force call to OnGlobalLayoutListener in inflated view -


"itemprop =" text ">

I am extending a scene using call

  last view view = MActivity.getLayoutInflater () .inflet (R.Latite.photo_view, empty, incorrect);  

The view is being inflated to the sole purpose of turning it into a bitmap.

The following call is not being made. Now if I'd call in a DialogFragment the onCreateView - I know the code snippet only works but if I just grew scene to bitmap conversion method public void Global layout () is never said nothing

  Wutryobrhwar Wutryobersser = Wukgetwutryobsrhwar (); If (viewTreeObserver.isAlive ()) {Log.i (TAG, "Waiting for the right time"); View.getViewTreeObserver () AddOnGlobalLayoutListener (new ViewTreeObserver.OnGlobalLayoutListener () override public void on @GolobalLayout {@SuppressLint ( "NewApi") (if .height & lt (view.getLayoutParams). Width & lt; = 0 || view.getLayoutParams (); = 0) {int height = getDeviceHeight (mActivity); int width = getDeviceWidth (mActivity); LayoutParams layout = view.getLayoutParams (); layout.height = height; layout.width = width; view.setLayoutParams (layout);} doMyWork (see), if (Utils.hasJellyBean ()) {view.getViewTreeObserver () removeOnGlobalLayoutListener (this); ..} else {view.getViewTreeObserver () removeGlobalOnLayoutListener (this);}}}); }  

I want to make a non-zero amplitude to make my bitmap to say get null for the needs of this method because I otherwise, view.getDrawingCache () . So how do I force execution of after the viewTreeObserver.OnGlobalLayoutListener

your view is ever Do not connect to the window - it will never be kept by the frame. You must attach it to a window (such as taking it in your layout) or to measure it and keep it manually.

Integer width SEPEC = Measurement SPC makemaker SPEC (width, measurement SECEXActive) ; Int heightSpec = MeasureSpec.makeMeasureSpec (height, measurement. EXACTLY); See. Measurement (width SSPC, heightSPC); View.layout (view.getMeasuredWidth), view.getMeasuredHeight ());

No comments:

Post a Comment