當前位置: 首頁>>代碼示例>>Java>>正文


Java View.measure方法代碼示例

本文整理匯總了Java中android.view.View.measure方法的典型用法代碼示例。如果您正苦於以下問題:Java View.measure方法的具體用法?Java View.measure怎麽用?Java View.measure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.measure方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: measureHeight

import android.view.View; //導入方法依賴的package包/類
private int measureHeight(int measureSpec) {
	int mode = MeasureSpec.getMode(measureSpec);
	if (mode == MeasureSpec.AT_MOST) {
		return MeasureSpec.makeMeasureSpec(measureSpec, mode);
	} else if (mode == MeasureSpec.EXACTLY) {
		ListAdapter adapter = getAdapter();
		if (adapter == null) {
			measureSpec = 0;
		} else {
			int result = 0;
			for (int i = 0; i < adapter.getCount(); i++) {
				View contentView = adapter.getView(i, null, null);
				contentView.measure(0, 0);
				result += contentView.getMeasuredHeight();
			}
			measureSpec = result + getDividerHeight()
					* (adapter.getCount() - 1);
		}
	}

	return MeasureSpec.makeMeasureSpec(measureSpec, mode);
}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:23,代碼來源:SuperListView.java

示例2: measureContentWidth

import android.view.View; //導入方法依賴的package包/類
public int measureContentWidth() {
    // The user may have specified some of the target not to be shown but we
    // want to measure all of them since after expansion they should fit.
    final int oldMaxActivityCount = mMaxActivityCount;
    mMaxActivityCount = MAX_ACTIVITY_COUNT_UNLIMITED;

    int contentWidth = 0;
    View itemView = null;

    final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int count = getCount();

    for (int i = 0; i < count; i++) {
        itemView = getView(i, itemView, null);
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        contentWidth = Math.max(contentWidth, itemView.getMeasuredWidth());
    }

    mMaxActivityCount = oldMaxActivityCount;

    return contentWidth;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:24,代碼來源:ActivityChooserView.java

示例3: setExpandedListViewHeightBasedOnChildren

import android.view.View; //導入方法依賴的package包/類
public static void setExpandedListViewHeightBasedOnChildren(ExpandableListView listView, int groupPosition) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    if (listAdapter == null) {
        return;
    }
    View listItem = listAdapter.getChildView(groupPosition, 0, true, null,
            listView);
    listItem.measure(0, 0);
    int appendHeight = 0;
    for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) {
        appendHeight += listItem.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height += appendHeight;
    listView.setLayoutParams(params);
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:17,代碼來源:ExpandedListUtils.java

示例4: doInBackground

import android.view.View; //導入方法依賴的package包/類
@Nullable
@Override
protected final Bitmap doInBackground(@NonNull final Tab key,
                                      @NonNull final TabItem... params) {
    TabItem tabItem = params[0];
    PhoneTabViewHolder viewHolder = tabItem.getViewHolder();
    View child = viewHolder.child;
    viewHolder.child = null;
    int width = parent.getWidth();
    int height = parent.getHeight();
    child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
            MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    child.draw(canvas);
    return bitmap;
}
 
開發者ID:NeoTerm,項目名稱:NeoTerm,代碼行數:19,代碼來源:PreviewDataBinder.java

示例5: onMeasure

import android.view.View; //導入方法依賴的package包/類
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int cellWidthSpec = MeasureSpec.makeMeasureSpec(mCellWidth,
            MeasureSpec.AT_MOST);
    int cellHeightSpec = MeasureSpec.makeMeasureSpec(mCellHeight,
            MeasureSpec.AT_MOST);

    int count = getChildCount();
    for (int index=0; index<count; index++) {
        final View child = getChildAt(index);
        child.measure(cellWidthSpec, cellHeightSpec);
    }
    // Use the size our parents gave us
    setMeasuredDimension(resolveSize(mCellWidth*count, widthMeasureSpec),
            resolveSize(mCellHeight*count, heightMeasureSpec));
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:17,代碼來源:FixedGridLayout.java

示例6: getMenuOptionPopup

import android.view.View; //導入方法依賴的package包/類
/** A popup to select the type of message to send, "Text", "Image", "Location".*/
public static PopupWindow getMenuOptionPopup(Context context, View.OnClickListener listener){
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View popupView = inflater.inflate(R.layout.chat_sdk_popup_options, null);
    PopupWindow optionPopup = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
    popupView.findViewById(R.id.chat_sdk_btn_choose_picture).setOnClickListener(listener);
    popupView.findViewById(R.id.chat_sdk_btn_take_picture).setOnClickListener(listener);
    popupView.findViewById(R.id.chat_sdk_btn_location).setOnClickListener(listener);

    if (!BDefines.Options.LocationEnabled || context.getString(R.string.google_maps_api_key).isEmpty()){
        popupView.findViewById(R.id.chat_sdk_btn_location).setVisibility(View.GONE);
    }
    
    popupView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    // TODO fix popup size to wrap view size.
    optionPopup.setContentView(popupView);
    optionPopup.setBackgroundDrawable(new BitmapDrawable());
    optionPopup.setOutsideTouchable(true);
    optionPopup.setWidth(popupView.getMeasuredWidth());
    optionPopup.setHeight(popupView.getMeasuredHeight());
    return optionPopup;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:24,代碼來源:DialogUtils.java

示例7: resolveView

import android.view.View; //導入方法依賴的package包/類
/**
 * Updates View bounds, possibly re-measuring and re-layouting it if the size changed.
 *
 * @param reactTag reactTag to lookup a View by
 * @param left left coordinate relative to parent
 * @param top top coordinate relative to parent
 * @param right right coordinate relative to parent
 * @param bottom bottom coordinate relative to parent
 */
/* package */ void updateViewBounds(int reactTag, int left, int top, int right, int bottom) {
  View view = resolveView(reactTag);
  int width = right - left;
  int height = bottom - top;
  if (view.getWidth() != width || view.getHeight() != height) {
    // size changed, we need to measure and layout the View
    view.measure(
        MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
        MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    view.layout(left, top, right, bottom);
  } else {
    // same size, only location changed, there is a faster route.
    view.offsetLeftAndRight(left - view.getLeft());
    view.offsetTopAndBottom(top - view.getTop());
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:26,代碼來源:FlatNativeViewHierarchyManager.java

示例8: ensurePinnedHeaderLayout

import android.view.View; //導入方法依賴的package包/類
private void ensurePinnedHeaderLayout(View header, boolean forceLayout) {
    if (header.isLayoutRequested() || forceLayout) {
        int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
        int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
        try {
            header.measure(widthSpec, heightSpec);
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
        header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:13,代碼來源:SectionsListView.java

示例9: getSingleLineHeight

import android.view.View; //導入方法依賴的package包/類
@Override
    public int getSingleLineHeight() {
        //將所有類型彈幕的布局拿出來,找到高度最大值,作為彈道高度
        View view = LayoutInflater.from(context).inflate(R.layout.item_danmu, null);
        //指定行高
        view.measure(0, 0);

        View view2 = LayoutInflater.from(context).inflate(R.layout.item_super_danmu, null);
        //指定行高
        view2.measure(0, 0);

//        return Math.max(view.getMeasuredHeight(),view2.getMeasuredHeight());
        return view.getMeasuredHeight();
    }
 
開發者ID:hust201010701,項目名稱:XDanmuku,代碼行數:15,代碼來源:DanmuAdapter.java

示例10: measureView

import android.view.View; //導入方法依賴的package包/類
private void measureView(View v) {
	// See what size the view wants to be
	v.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

	if (!mReflow) {
	// Work out a scale that will fit it to this view
	float scale = Math.min((float)getWidth()/(float)v.getMeasuredWidth(),
				(float)getHeight()/(float)v.getMeasuredHeight());
	// Use the fitting values scaled by our current scale factor
	v.measure(View.MeasureSpec.EXACTLY | (int)(v.getMeasuredWidth()*scale*mScale),
			View.MeasureSpec.EXACTLY | (int)(v.getMeasuredHeight()*scale*mScale));
	} else {
		v.measure(View.MeasureSpec.EXACTLY | (int)(v.getMeasuredWidth()),
				View.MeasureSpec.EXACTLY | (int)(v.getMeasuredHeight()));
	}
}
 
開發者ID:ArtifexSoftware,項目名稱:mupdf-android-viewer-old,代碼行數:17,代碼來源:ReaderView.java

示例11: measureView

import android.view.View; //導入方法依賴的package包/類
private void measureView(View child) {
    int childHeightSpec;
    ViewGroup.LayoutParams p = child.getLayoutParams();
    if (p == null) {
        p = new ViewGroup.LayoutParams(-1, -2);
    }
    int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0, p.width);
    int lpHeight = p.height;
    if (lpHeight > 0) {
        childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, 1073741824);
    } else {
        childHeightSpec = MeasureSpec.makeMeasureSpec(0, 0);
    }
    child.measure(childWidthSpec, childHeightSpec);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:16,代碼來源:PullToRefreshBase.java

示例12: measureChildWithMargins

import android.view.View; //導入方法依賴的package包/類
public void measureChildWithMargins(View child, int widthUsed, int heightUsed) {
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    Rect insets = this.mRecyclerView.getItemDecorInsetsForChild(child);
    heightUsed += insets.top + insets.bottom;
    int widthSpec = getChildMeasureSpec(getWidth(), getWidthMode(), (((getPaddingLeft() + getPaddingRight()) + lp.leftMargin) + lp.rightMargin) + (widthUsed + (insets.left + insets.right)), lp.width, canScrollHorizontally());
    int heightSpec = getChildMeasureSpec(getHeight(), getHeightMode(), (((getPaddingTop() + getPaddingBottom()) + lp.topMargin) + lp.bottomMargin) + heightUsed, lp.height, canScrollVertically());
    if (shouldMeasureChild(child, widthSpec, heightSpec, lp)) {
        child.measure(widthSpec, heightSpec);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:RecyclerView.java

示例13: bindLayoutView

import android.view.View; //導入方法依賴的package包/類
public void bindLayoutView(@NonNull final View layoutView) {
    layoutView.measure(View.MeasureSpec.makeMeasureSpec(mLayoutRegion.width(), View.MeasureSpec.EXACTLY),
        View.MeasureSpec.makeMeasureSpec(mLayoutRegion.height(), View.MeasureSpec.EXACTLY));
    layoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
    layoutView.setBackgroundColor(mBgColor);

    if (mLayoutViewBindListener != null) {
        mLayoutViewBindListener.onBind(layoutView, getLayoutHelper());
    }

    // reset region rectangle
    mLayoutRegion.set(0, 0, 0, 0);
}
 
開發者ID:alibaba,項目名稱:vlayout,代碼行數:14,代碼來源:RangeStyle.java

示例14: createRefreshableView

import android.view.View; //導入方法依賴的package包/類
/**
 * 設置布局內容
 */
@Override
protected FrameLayout createRefreshableView(Context context, AttributeSet attrs) {
    FrameLayout frameLayout = new FrameLayout(context);
    View v = LayoutInflater.from(context).inflate(R.layout.activity_with_bottom_tab_content, null);
    v.measure(View.MeasureSpec.AT_MOST, View.MeasureSpec.AT_MOST);
    frameLayout.addView(v);
    return frameLayout;
}
 
開發者ID:103style,項目名稱:RefreshWithAppBarLayout,代碼行數:12,代碼來源:WithBottomContentView.java

示例15: addViewHolder

import android.view.View; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private void addViewHolder(int row, int column, int itemType) {
    boolean createdNewView;
    // need to add new one
    ViewHolder viewHolder = mRecycler.popRecycledViewHolder(itemType);
    createdNewView = viewHolder == null;
    if (createdNewView) {
        viewHolder = createViewHolder(itemType);
    }

    if (viewHolder == null) {
        return;
    }

    // prepare view holder
    viewHolder.setRowIndex(row);
    viewHolder.setColumnIndex(column);
    viewHolder.setItemType(itemType);
    View view = viewHolder.getItemView();

    view.setTag(R.id.tag_view_holder, viewHolder);
    // add view to the layout
    addView(view, 0);

    // save and measure view holder
    if (itemType == ViewHolderType.ITEM) {
        mViewHolders.put(row, column, viewHolder);
        if (createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindViewHolder(viewHolder, row, getBindColumn(column));
        }
        view.measure(
                MeasureSpec.makeMeasureSpec(mManager.getColumnWidth(column), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(mManager.getRowHeight(row), MeasureSpec.EXACTLY));
        refreshItemViewHolder(viewHolder);
        if (!createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindViewHolder(viewHolder, row, getBindColumn(column));
        }


    } else if (itemType == ViewHolderType.ROW_HEADER) {
        mHeaderRowViewHolders.put(row, viewHolder);
        if (createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindHeaderRowViewHolder(viewHolder, row);
        }
        view.measure(
                MeasureSpec.makeMeasureSpec(mManager.getHeaderRowWidth(), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(mManager.getRowHeight(row), MeasureSpec.EXACTLY));

        refreshHeaderRowViewHolder(viewHolder);
        if (!createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindHeaderRowViewHolder(viewHolder, row);
        }

    } else if (itemType == ViewHolderType.COLUMN_HEADER) {
        mHeaderColumnViewHolders.put(column, viewHolder);
        if (createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindHeaderColumnViewHolder(viewHolder, getBindColumn(column));
        }
        view.measure(
                MeasureSpec.makeMeasureSpec(mManager.getColumnWidth(column), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(mManager.getHeaderColumnHeight(), MeasureSpec.EXACTLY));

        refreshHeaderColumnViewHolder(viewHolder);

        if (!createdNewView) {
            // DO NOT REMOVE THIS!! Fix bug with request layout "requestLayout() improperly called"
            mAdapter.onBindHeaderColumnViewHolder(viewHolder, getBindColumn(column));
        }
    }
}
 
開發者ID:Cleveroad,項目名稱:AdaptiveTableLayout,代碼行數:76,代碼來源:AdaptiveTableLayout.java


注:本文中的android.view.View.measure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。