当前位置: 首页>>代码示例>>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;未经允许,请勿转载。