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


Java ViewGroup.measure方法代碼示例

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


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

示例1: measureViewGroupHeight

import android.view.ViewGroup; //導入方法依賴的package包/類
private static int measureViewGroupHeight(ViewGroup viewGroup) {
    View parent = (View) viewGroup.getParent();
    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(
            parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(),
            View.MeasureSpec.AT_MOST);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    viewGroup.measure(widthMeasureSpec, heightMeasureSpec);
    return viewGroup.getMeasuredHeight();
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:10,代碼來源:DragUtils.java

示例2: show

import android.view.ViewGroup; //導入方法依賴的package包/類
public void show(Context content,View locationView,String[] menuLabelArray,OnPopMultiMenuClick onPopMultiMenuClick){
        try {
            //check
            if(menuLabelArray==null || menuLabelArray.length<1){
                throw new RuntimeException(" menu label can not be empty ");
            }

            // ready
            LayoutInflater layoutInflater=LayoutInflater.from(content);
            mOnPopMultiMenuClick = onPopMultiMenuClick;

            // 如果隻有一個,則把divider刪除掉
            ViewGroup popupView =(ViewGroup) layoutInflater.inflate(R.layout.udesk_multi_horizontal_popmenu, null);

            // 把菜單都添加進去
            addChildView(popupView,layoutInflater,menuLabelArray);
            setContentView(popupView);


            // 測繪並定位
            popupView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
            int popupWidth = popupView.getMeasuredWidth();
            int popupHeight =  popupView.getMeasuredHeight();
            setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
            setHeight(popupHeight);

            //顯示出來
            int[] location = new int[2];
            locationView.getLocationOnScreen(location);

            showAtLocation(locationView, Gravity.NO_GRAVITY , /*location[0]*/(location[0]+locationView.getWidth()/2)-popupWidth/2,
                    location[1]-popupHeight/*location[1]- getHeight()*/);
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    } 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:37,代碼來源:UdeskMultiMenuHorizontalWindow.java


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