android WView: requestLayout() improperly called by xxxView

    xiaoxiao2022-06-29  31

    2328     private void performLayout(WindowManager.LayoutParams lp, int desiredWindowWidth,

    2329             int desiredWindowHeight) { 2330         mLayoutRequested = false; 2331         mScrollMayChange = true; 2332         mInLayout = true; 2333  2334         final View host = mView; 2335         if (DEBUG_ORIENTATION || DEBUG_LAYOUT) { 2336             Log.v(mTag, "Laying out " + host + " to (" + 2337                     host.getMeasuredWidth() + ", " + host.getMeasuredHeight() + ")"); 2338         } 2339  2340         Trace.traceBegin(Trace.TRACE_TAG_VIEW, "layout"); 2341         try { 2342             host.layout(0, 0, host.getMeasuredWidth(), host.getMeasuredHeight()); 2343  2344             mInLayout = false; 2345             int numViewsRequestingLayout = mLayoutRequesters.size(); 2346             if (numViewsRequestingLayout > 0) { 2347                 // requestLayout() was called during layout. 2348                 // If no layout-request flags are set on the requesting views, there is no problem. 2349                 // If some requests are still pending, then we need to clear those flags and do 2350                 // a full request/measure/layout pass to handle this situation. 2351                 ArrayList<View> validLayoutRequesters = getValidLayoutRequesters(mLayoutRequesters, 2352                         false); 2353                 if (validLayoutRequesters != null) { 2354                     // Set this flag to indicate that any further requests are happening during 2355                     // the second pass, which may result in posting those requests to the next 2356                     // frame instead 2357                     mHandlingLayoutInLayoutRequest = true; 2358  2359                     // Process fresh layout requests, then measure and layout 2360                     int numValidRequests = validLayoutRequesters.size(); 2361                     for (int i = 0; i < numValidRequests; ++i) { 2362                         final View view = validLayoutRequesters.get(i); 2363                         Log.w("View", "requestLayout() improperly called by " + view + 2364                                 " during layout: running second layout pass"); 2365                         view.requestLayout(); 2366                     } 2367                     measureHierarchy(host, lp, mView.getContext().getResources(), 2368                             desiredWindowWidth, desiredWindowHeight); 2369                     mInLayout = true;  2370                     host.layout(0, 0, host.getMeasuredWidth(), host.getMeasuredHeight()); 2371  2372                     mHandlingLayoutInLayoutRequest = false; 2373  2374                     // Check the valid requests again, this time without checking/clearing the 2375                     // layout flags, since requests happening during the second pass get noop'd 2376                     validLayoutRequesters = getValidLayoutRequesters(mLayoutRequesters, true); 2377                     if (validLayoutRequesters != null) { 2378                         final ArrayList<View> finalRequesters = validLayoutRequesters; 2379                         // Post second-pass requests to the next frame 2380                         getRunQueue().post(new Runnable() { 2381                             @Override 2382                             public void run() { 2383                                 int numValidRequests = finalRequesters.size(); 2384                                 for (int i = 0; i < numValidRequests; ++i) {
    转载请注明原文地址: https://ju.6miu.com/read-1125206.html

    最新回复(0)