public void markChildrenDirty() { if (mViewTypeCount == 1) { final Stack<View> scrap = mCurrentScrap; final int scrapCount = scrap.size(); for (int i = 0; i < scrapCount; i++) { scrap.get(i).forceLayout(); } } else { final int typeCount = mViewTypeCount; for (int i = 0; i < typeCount; i++) { final Stack<View> scrap = mScrapViews[i]; final int scrapCount = scrap.size(); for (int j = 0; j < scrapCount; j++) { scrap.get(j).forceLayout(); } } } }
public int measureCellWidth( Context context, View cell ) { // We need a fake parent FrameLayout buffer = new FrameLayout( context ); android.widget.AbsListView.LayoutParams layoutParams = new android.widget.AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); buffer.addView( cell, layoutParams); cell.forceLayout(); cell.measure(1000, 1000); int width = cell.getMeasuredWidth(); buffer.removeAllViews(); return width; }
/** * Subclasses should NOT override this method but * {@link #layoutChildren()} instead. */ @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); mInLayout = true; if (changed) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { getChildAt(i).forceLayout(); } mRecycler.markChildrenDirty(); } layoutChildren(); mInLayout = false; }
child.forceLayout(); if (i > 0) {
@Override public View getView(int position, View convertView, ViewGroup parent) { Position adapterPosition = translatePosition(position); if (adapterPosition.mPosition == POSITION_HEADER) { HeaderFillerView v = getHeaderFillerView(adapterPosition.mHeader, convertView, parent); View view = mDelegate.getHeaderView(adapterPosition.mHeader, (View)v.getTag(), parent); mGridView.detachHeader((View) v.getTag()); v.setTag(view); mGridView.attachHeader(view); convertView = v; mLastHeaderViewSeen = v; v.forceLayout(); } else if (adapterPosition.mPosition == POSITION_HEADER_FILLER) { convertView = getFillerView(convertView, parent, mLastHeaderViewSeen); convertView.forceLayout(); } else if (adapterPosition.mPosition == POSITION_FILLER) { convertView = getFillerView(convertView, parent, mLastViewSeen); } else { convertView = mDelegate.getView(adapterPosition.mPosition, convertView, parent); mLastViewSeen = convertView; } return convertView; }
public int measureCellWidth( Context context, View cell ) { // We need a fake parent FrameLayout buffer = new FrameLayout( context ); android.widget.AbsListView.LayoutParams layoutParams = new android.widget.AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); buffer.addView( cell, layoutParams); cell.forceLayout(); cell.measure(1000, 1000); int width = cell.getMeasuredWidth(); buffer.removeAllViews(); return width; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { if (null == convertView) { convertView = mInflater.inflate( R.layout.mnm_customer_user_thumbnail, null); control.txtUserName = (TextView) convertView .findViewById(R.id.mnmTxtStudentName); control.image = (ImageView) convertView .findViewById(R.id.mnmImageStudent); control.imageCheckBox = (ImageView) convertView .findViewById(R.id.mnmImageCheckBox); control.mnmOuterBounder = (RelativeLayout) convertView .findViewById(R.id.mnmOuterBound); convertView.setTag(control); } else { convertView.forceLayout(); } ... ... ... ...
public static void forceLayoutAndroid19 (ViewGroup vg) { if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.KITKAT) { for (int i = 0, limit = vg.getChildCount (); i < limit; i++) { View child = vg.getChildAt (i); child.forceLayout (); if (child instanceof ViewGroup) forceLayoutAndroid19 ((ViewGroup)child); } } }
public void markChildrenDirty() { if ( mViewTypeCount == 1 ) { final ArrayList<View> scrap = mCurrentScrap; final int scrapCount = scrap.size(); for ( int i = 0; i < scrapCount; i++ ) { scrap.get( i ).forceLayout(); } } else { final int typeCount = mViewTypeCount; for ( int i = 0; i < typeCount; i++ ) { final ArrayList<View> scrap = mScrapViews[i]; final int scrapCount = scrap.size(); for ( int j = 0; j < scrapCount; j++ ) { scrap.get( j ).forceLayout(); } } } if ( mTransientStateViews != null ) { final int count = mTransientStateViews.size(); for ( int i = 0; i < count; i++ ) { mTransientStateViews.valueAt( i ).forceLayout(); } } }
@Override protected void onScrollTouchedUp() { super.onScrollTouchedUp(); int cnt = mItemsLayout.getChildCount(); View itm; Log.e(LOG_TAG, " ----- layout: " + mItemsLayout.getMeasuredWidth() + mItemsLayout.getMeasuredHeight()); Log.e(LOG_TAG, " -------- dumping " + cnt + " items"); for (int i = 0; i < cnt; i++) { itm = mItemsLayout.getChildAt(i); Log.e(LOG_TAG, " item #" + i + ": " + itm.getWidth() + "x" + itm.getHeight()); itm.forceLayout(); // forcing layout without re-rendering parent } Log.e(LOG_TAG, " ---------- dumping finished "); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { // TODO Auto-generated method stub super.onLayout(changed, left, top, right, bottom); mInLayout = true; final int childCount = getChildCount(); if (changed) { for (int i = 0; i < childCount; i++) { getChildAt(i).forceLayout(); } } layoutChildren(); mInLayout = false; }
/** * Subclasses should NOT override this method but {@link #layoutChildren()} instead. */ @Override protected void onLayout( boolean changed, int l, int t, int r, int b ) { super.onLayout( changed, l, t, r, b ); mInLayout = true; if ( changed ) { int childCount = getChildCount(); for ( int i = 0; i < childCount; i++ ) { getChildAt( i ).forceLayout(); } mRecycler.markChildrenDirty(); } layoutChildren(); mInLayout = false; mOverscrollMax = ( r - l ) / OVERSCROLL_LIMIT_DIVISOR; }
@Override public View getView(int position, View convertView, ViewGroup parent) { Position adapterPosition = translatePosition(position); if (adapterPosition.mPosition == POSITION_HEADER) { HeaderFillerView v = getHeaderFillerView(adapterPosition.mHeader, convertView, parent); View view = mDelegate.getHeaderView(adapterPosition.mHeader, (View)v.getTag(), parent); mGridView.detachHeader((View) v.getTag()); v.setTag(view); mGridView.attachHeader(view); convertView = v; mLastHeaderViewSeen = v; v.forceLayout(); } else if (adapterPosition.mPosition == POSITION_HEADER_FILLER) { convertView = getFillerView(convertView, parent, mLastHeaderViewSeen); convertView.forceLayout(); } else if (adapterPosition.mPosition == POSITION_FILLER) { convertView = getFillerView(convertView, parent, mLastViewSeen); } else { convertView = mDelegate.getView(adapterPosition.mPosition, convertView, parent); mLastViewSeen = convertView; } return convertView; }