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


Java ViewGroup.LayoutParams方法代碼示例

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


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

示例1: adaptStatusBar

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * Android 4.4時,設置狀態欄透明,來適配標題欄樣式
 */
private void adaptStatusBar() {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
        if (mToolbar != null) {
            WindowManager.LayoutParams localLayoutParams = getAttachActivity().getWindow().getAttributes();
            localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);

            int toolbarHeight = (int)getResources().getDimension(R.dimen.tool_bar_height_adapt);
            ViewGroup.LayoutParams layoutParams = mToolbar.getLayoutParams();
            layoutParams.height = toolbarHeight;

            int toolbarPaddingTop = (int) getResources().getDimension(R.dimen.tool_bar_padding_top);
            mToolbar.setPadding(0, toolbarPaddingTop, 0, 0);
        }
    }
}
 
開發者ID:Sugarya,項目名稱:FragmentCapsulation,代碼行數:19,代碼來源:BasicToolbarFragment.java

示例2: measureView

import android.view.ViewGroup; //導入方法依賴的package包/類
private void measureView(View child) {
    ViewGroup.LayoutParams p = child.getLayoutParams();
    if (p == null) {
        p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0, p.width);
    int lpHeight = p.height;
    int childHeightSpec;
    if (lpHeight > 0) {
        childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
    } else {
        childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    }
    child.measure(childWidthSpec, childHeightSpec);
}
 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:17,代碼來源:UDPullGetMoreListView.java

示例3: onStateChanged

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public void onStateChanged(View bottomSheet, int newState) {
    switch (newState) {
        case ViewPagerBottomSheetBehavior.STATE_HIDDEN:
            if (callbacks != null) {
                callbacks.onResult("swiped_down");
            }
            dismiss();
            break;
        case ViewPagerBottomSheetBehavior.STATE_COLLAPSED:
            ViewGroup.LayoutParams params = view_main.getLayoutParams();
            params.height = ViewGroup.LayoutParams.MATCH_PARENT;
            view_main.setLayoutParams(params);
            break;
        case ViewPagerBottomSheetBehavior.STATE_EXPANDED:
            ViewGroup.LayoutParams params1 = view_main.getLayoutParams();
            params1.height = ViewGroup.LayoutParams.MATCH_PARENT;
            view_main.setLayoutParams(params1);
            break;
    }

}
 
開發者ID:Krupen,項目名稱:FabulousFilter,代碼行數:23,代碼來源:AAH_FabulousFragment.java

示例4: measureView

import android.view.ViewGroup; //導入方法依賴的package包/類
private void measureView(View child) {
    ViewGroup.LayoutParams p = child.getLayoutParams();
    if (p == null) {
        p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width);
    int lpHeight = p.height;
    int childHeightSpec;
    if (lpHeight > 0) {
        childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight,
                MeasureSpec.EXACTLY);
    } else {
        childHeightSpec = MeasureSpec.makeMeasureSpec(0,
                MeasureSpec.UNSPECIFIED);
    }
    child.measure(childWidthSpec, childHeightSpec);
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:19,代碼來源:DropdownListView.java

示例5: setHeight

import android.view.ViewGroup; //導入方法依賴的package包/類
private void setHeight(int height) {
    if (mParent != null) {
        ViewGroup.LayoutParams params = mParent.getLayoutParams();
        params.height = height;
        mParent.requestLayout();
        viewChanged();
    }
}
 
開發者ID:morogoku,項目名稱:MTweaks-KernelAdiutorMOD,代碼行數:9,代碼來源:DropDownView.java

示例6: setDrawableArrowSizePx

import android.view.ViewGroup; //導入方法依賴的package包/類
public ClassicsFooter setDrawableArrowSizePx(int px) {
    ViewGroup.LayoutParams lpArrow = mArrowView.getLayoutParams();
    lpArrow.width = px;
    lpArrow.height = px;
    mArrowView.setLayoutParams(lpArrow);
    return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:ClassicsFooter.java

示例7: handleMeasuredStateTooSmall

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * Iterates over children and checks if any of them would like to get more space than it
 * received through the percentage dimension.
 *
 * If you are building a layout that supports percentage dimensions you are encouraged to take
 * advantage of this method. The developer should be able to specify that a child should be
 * remeasured by adding normal dimension attribute with {@code wrap_content} value. For example
 * he might specify child's attributes as {@code app:layout_widthPercent="60%p"} and
 * {@code android:layout_width="wrap_content"}. In this case if the child receives too little
 * space, it will be remeasured with width set to {@code WRAP_CONTENT}.
 *
 * @return True if the measure phase needs to be rerun because one of the children would like
 * to receive more space.
 */
public boolean handleMeasuredStateTooSmall() {
    boolean needsSecondMeasure = false;
    for (int i = 0, N = mHost.getChildCount(); i < N; i++) {
        View view = mHost.getChildAt(i);
        ViewGroup.LayoutParams params = view.getLayoutParams();
        if (DEBUG) {
            Log.d(TAG, "should handle measured state too small " + view + " " + params);
        }
        if (params instanceof PercentLayoutParams) {
            PercentLayoutInfo info =
                    ((PercentLayoutParams) params).getPercentLayoutInfo();
            if (info != null) {
                if (shouldHandleMeasuredWidthTooSmall(view, info)) {
                    needsSecondMeasure = true;
                    params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
                }
                if (shouldHandleMeasuredHeightTooSmall(view, info)) {
                    needsSecondMeasure = true;
                    params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
                }
            }
        }
    }
    if (DEBUG) {
        Log.d(TAG, "should trigger second measure pass: " + needsSecondMeasure);
    }
    return needsSecondMeasure;
}
 
開發者ID:liu-xiao-dong,項目名稱:JD-Test,代碼行數:43,代碼來源:PercentLayoutHelper.java

示例8: addStateViewLayoutParams

import android.view.ViewGroup; //導入方法依賴的package包/類
protected void addStateViewLayoutParams(View view) {
    ViewGroup.LayoutParams lp = view.getLayoutParams();
    if (lp == null) {
        lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        view.setLayoutParams(lp);
    }
}
 
開發者ID:dkzwm,項目名稱:SmoothRefreshLayout,代碼行數:8,代碼來源:SmoothRefreshLayout.java

示例9: getMarginBottom

import android.view.ViewGroup; //導入方法依賴的package包/類
private int getMarginBottom() {
    int marginBottom = 0;
    final ViewGroup.LayoutParams layoutParams = getLayoutParams();
    if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
        marginBottom = ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
    }
    return marginBottom;
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:9,代碼來源:FloatingActionButton.java

示例10: addStatusBar

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * @return
 * @throws
 * @fuction 初始化並加載我們的狀態欄背景,我們添加的這個背景,
 * 不是添加在Activit的布局中,而是Activity的contextFrameLayout中設置作為狀態欄背景的View的屬性
 * @parm
 */
@TargetApi(19)
@Override
public void addStatusBar() {
    if((request.isTrans()==request.isImageAsBg())) {
        Window window = request.getActivity().getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ViewGroup.LayoutParams layoutParams =
                new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        request.getStatusBarHeigth());
        addMyStatusView(layoutParams);
    }
}
 
開發者ID:ljh998,項目名稱:BAStatusBarLib,代碼行數:20,代碼來源:AddBarAftreKiK.java

示例11: setContentView

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
    super.setContentView(view, params);
    ViewGroup viewGroup = (ViewGroup) view;
    if (viewGroup.getChildCount() > 0) {
        dialogContent = viewGroup.getChildAt(0);
        if (dialogContent != null) {
            dialogContent.setVisibility(View.INVISIBLE);
        }
    }
}
 
開發者ID:harrylefit,項目名稱:EazyBaseMVP,代碼行數:12,代碼來源:BaseAnimationDialog.java

示例12: adjustSize

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 改變外框大小,適應文字
 * 如果當前文字隻有一行,則縮到外框適應文字大小
 * 如果文字有多行,則寬度不變,縮小高度到適應文字大小
 * 文字外框的位置不變
 *
 * @param view
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void adjustSize(TextView view) {
    if (view != null && view.getLayoutParams() != null) {
        /*
        //更好的實現方式,但是ios那邊不支持這種方式
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        view.setLayoutParams(layoutParams);*/

        // 廢棄的實現方式,使用WRAP_CONTENT最簡單,且這種方式算出來的width有bug
        // @Deprecated
        /*int lineCount = Math.min(view.getLineCount(), getMaxLines(view));
        int width, height;
        if (lineCount > 1) {//多行,寬度不變,改變高度
            width = view.getWidth();
            height = view.getLineHeight() * lineCount + view.getPaddingTop() + view.getPaddingBottom();
        } else {//一行,改變寬度&高度
            final Paint paint = view.getPaint();
            width = (int) paint.measureText(view.getText().toString()) + view.getPaddingLeft() + view.getPaddingRight();
            height = view.getLineHeight() + view.getPaddingTop() + view.getPaddingBottom();
        }*/

        int lineCount = Math.min(view.getLineCount(), getMaxLines(view));
        float width, height;
        if (lineCount > 1) {//多行,寬度不變,改變高度
            width = view.getWidth();
            height = view.getLineHeight() * lineCount + view.getPaddingTop() + view.getPaddingBottom();
        } else {//一行,改變寬度&高度
            width = view.getPaddingLeft() + Layout.getDesiredWidth(view.getText(), view.getPaint()) + view.getPaddingRight();
            height = view.getLineHeight() + view.getPaddingTop() + view.getPaddingBottom();
        }

        if (view.getLayoutParams() != null) {
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            layoutParams.width = (int) width;
            layoutParams.height = (int) height;
            view.setLayoutParams(layoutParams);
        }
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:50,代碼來源:TextUtil.java

示例13: setContentView

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
    getDelegate().setContentView(view, params);
}
 
開發者ID:bjaanes,項目名稱:BeaconMqtt,代碼行數:5,代碼來源:AppCompatPreferenceActivity.java

示例14: addView

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public void addView(View child, ViewGroup.LayoutParams params) {
    if (child.getId() == R.id.pw_rlMainContainer) {
        super.addView(child, params);
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:7,代碼來源:PlayLayout.java

示例15: LayoutParams

import android.view.ViewGroup; //導入方法依賴的package包/類
public LayoutParams(ViewGroup.LayoutParams source) {
    super(source);
}
 
開發者ID:scwang90,項目名稱:SmartRefreshLayout,代碼行數:4,代碼來源:SmartRefreshLayout.java


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