当前位置: 首页>>代码示例>>Java>>正文


Java ViewGroup.MarginLayoutParams方法代码示例

本文整理汇总了Java中android.view.ViewGroup.MarginLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.MarginLayoutParams方法的具体用法?Java ViewGroup.MarginLayoutParams怎么用?Java ViewGroup.MarginLayoutParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.MarginLayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTranslucentImageHeader

import android.view.ViewGroup; //导入方法依赖的package包/类
public static void setTranslucentImageHeader(Activity activity, int alpha,View needOffsetView){
    setFullScreen(activity);
    //获取windowphone下的decorView
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int       count     = decorView.getChildCount();
    //判断是否已经添加了statusBarView
    if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
        decorView.getChildAt(count - 1).setBackgroundColor(Color.argb(alpha, 0, 0, 0));
    } else {
        //新建一个和状态栏高宽的view
        StatusBarView statusView = createTranslucentStatusBarView(activity, alpha);
        decorView.addView(statusView);
    }

    if (needOffsetView != null) {
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
        layoutParams.setMargins(0, getStatusBarHeight(activity), 0, 0);
    }

}
 
开发者ID:zhao-mingjian,项目名称:qvod,代码行数:21,代码来源:StatusBarUtils.java

示例2: onViewAttached

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void onViewAttached(View view) {
    ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(getSelfView().getBinding().cvContainer.getLayoutParams());
    int margin0 = (int) getContext().getResources().getDimension(R.dimen.common_gap);
    int margin1 = (int) getContext().getResources().getDimension(R.dimen.common_gap_medium);
    int margin2 = (int) getContext().getResources().getDimension(R.dimen.common_gap_small);
    int margin3 = (int) getContext().getResources().getDimension(R.dimen.common_gap_medium);
    if (getSelfView() instanceof AdapterInterface) {
        AdapterInterface ai = ((AdapterInterface) getSelfView());
        if (ai.getViewHolder().getLayoutPosition() == 0) {
            lp.setMargins(margin1, margin0, 0, margin3);
        } else if (ai.getViewHolder().getLayoutPosition() == ai.getAdapter().size() - 1) {
            lp.setMargins(margin2, margin0, margin1, margin3);
        } else {
            lp.setMargins(margin2, margin0, 0, margin3);
        }
    }
    getSelfView().getBinding().cvContainer.setLayoutParams(lp);
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:20,代码来源:StaffDetailWorkItemViewModel.java

示例3: setupUserView

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 配置Activity。主要配置Activity的用户视图对状态栏和导航栏的留白
 *
 * @param activity Activity对象,不可为空
 * @throws IllegalStateException
 */
private void setupUserView(@NonNull Activity activity) throws IllegalStateException {
    ViewGroup contentViewGroup = (ViewGroup) activity.findViewById(android.R.id.content);
    final int childViewCount = contentViewGroup.getChildCount();
    if (childViewCount == 0) {
        throw new IllegalStateException("Plz invoke setContentView() method first!");
    } else if (childViewCount > 1) {
        throw new IllegalStateException("Plz set one view in SetContentView() or shouldn't use merge tag!!");
    }

    View userView = contentViewGroup.getChildAt(0);
    userView.setFitsSystemWindows(false);
    ViewGroup.MarginLayoutParams userViewParams = (ViewGroup.MarginLayoutParams) userView.getLayoutParams();
    userViewParams.topMargin += ImmerseGlobalConfig.getInstance().getStatusBarHeight();
    userView.setLayoutParams(userViewParams);
}
 
开发者ID:ls1110924,项目名称:ImmerseMode,代码行数:22,代码来源:TlSbNNbImmerseMode.java

示例4: onViewCreated

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getMainActivity().getSlidingUpPanelLayout().setShadowHeight(8);
    setStatusbarColorAuto(view);
    getMainActivity().setTaskDescriptionColorAuto();
    getMainActivity().setNavigationbarColorAuto();
    getMainActivity().setBottomBarVisibility(View.GONE);
    getMainActivity().hideStatusBar();

    /*Adding margin to toolbar for !full screen mode*/
    if (!PreferenceUtil.getInstance(getContext()).getFullScreenMode()) {
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mToolbar.getLayoutParams();
        params.topMargin = getResources().getDimensionPixelOffset(R.dimen.status_bar_padding);
        mToolbar.setLayoutParams(params);
    }

    setupToolbar();
    setupAdapter();
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:21,代码来源:HomeFragment.java

示例5: renderLayout

import android.view.ViewGroup; //导入方法依赖的package包/类
protected void renderLayout(BaseCell cell, View view) {
    if (cell.style != null) {
        ViewGroup.LayoutParams lp = view.getLayoutParams();

        if (lp == null || !(lp instanceof VirtualLayoutManager.LayoutParams)) {
            if (lp == null) {
                lp = new VirtualLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            } else {
                lp = new VirtualLayoutManager.LayoutParams(lp.width, lp.height);
            }
            view.setLayoutParams(lp);
        }
        if (lp instanceof VirtualLayoutManager.LayoutParams) {
            VirtualLayoutManager.LayoutParams params = (VirtualLayoutManager.LayoutParams) lp;

            if (cell.style.height >= 0) {
                params.storeOriginHeight();
                params.height = cell.style.height;
            } else {
                params.restoreOriginHeight();
            }

            if (cell.style.width >= 0) {
                params.storeOriginWidth();
                params.width = cell.style.width;
            } else {
                params.restoreOriginWidth();
            }

            params.mAspectRatio = cell.style.aspectRatio;

            params.zIndex = cell.style.zIndex;
            if (params.zIndex == 0) {
                if (cell.parent != null && cell.parent.style != null) {
                    params.zIndex = cell.parent.style.zIndex;
                }
            }
            if (VERSION.SDK_INT >= 21) {
                view.setZ(params.zIndex);
            }
        } else {
            if (cell.style.height >= 0) {
                lp.height = cell.style.height;
            }

            if (cell.style.width >= 0) {
                lp.width = cell.style.width;
            }
        }


        if (lp instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) lp;
            layoutParams.topMargin = cell.style.margin[MARGIN_TOP_INDEX];
            layoutParams.leftMargin = cell.style.margin[MARGIN_LEFT_INDEX];
            layoutParams.bottomMargin = cell.style.margin[MARGIN_BOTTOM_INDEX];
            layoutParams.rightMargin = cell.style.margin[MARGIN_RIGHT_INDEX];
        }

        // reset translation animation before reused
        view.setTranslationX(0);
        view.setTranslationY(0);
    }
}
 
开发者ID:alibaba,项目名称:Tangram-Android,代码行数:65,代码来源:MVHelper.java

示例6: changeAdapter

import android.view.ViewGroup; //导入方法依赖的package包/类
private void changeAdapter() {
    removeAllViews();
    TagAdapter adapter = mTagAdapter;
    TagView tagViewContainer = null;
    HashSet preCheckedList = mTagAdapter.getPreCheckedList();
    for (int i = 0; i < adapter.getCount(); i++) {
        View tagView = adapter.getView(this, i, adapter.getItem(i));

        tagViewContainer = new TagView(getContext());
        tagView.setDuplicateParentStateEnabled(true);
        if (tagView.getLayoutParams() != null) {
            tagViewContainer.setLayoutParams(tagView.getLayoutParams());
        } else {
            ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            lp.setMargins(dip2px(getContext(), 5),
                    dip2px(getContext(), 5),
                    dip2px(getContext(), 5),
                    dip2px(getContext(), 5));
            tagViewContainer.setLayoutParams(lp);
        }
        tagViewContainer.addView(tagView);
        addView(tagViewContainer);


        if (preCheckedList.contains(i)) {
            tagViewContainer.setChecked(true);
        }

        if (mTagAdapter.setSelected(i, adapter.getItem(i))) {
            mSelectedView.add(i);
            tagViewContainer.setChecked(true);
        }
    }
    mSelectedView.addAll(preCheckedList);

}
 
开发者ID:outliner,项目名称:propsshow,代码行数:37,代码来源:TagFlowLayout.java

示例7: initDefaultHeaderOffset

import android.view.ViewGroup; //导入方法依赖的package包/类
private void initDefaultHeaderOffset(Rect headerMargins, RecyclerView recyclerView, View header, View firstView, int orientation) {
    int translationX, translationY;
    mDimensionCalculator.initMargins(mTempRect1, header);

    ViewGroup.LayoutParams layoutParams = firstView.getLayoutParams();
    int leftMargin = 0;
    int topMargin = 0;
    if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
        leftMargin = marginLayoutParams.leftMargin;
        topMargin = marginLayoutParams.topMargin;
    }

    if (orientation == LinearLayoutManager.VERTICAL) {
        translationX = firstView.getLeft() - leftMargin + mTempRect1.left;
        translationY = Math.max(
                firstView.getTop() - topMargin - header.getHeight() - mTempRect1.bottom,
                getListTop(recyclerView) + mTempRect1.top);
    } else {
        translationY = firstView.getTop() - topMargin + mTempRect1.top;
        translationX = Math.max(
                firstView.getLeft() - leftMargin - header.getWidth() - mTempRect1.right,
                getListLeft(recyclerView) + mTempRect1.left);
    }

    headerMargins.set(translationX, translationY, translationX + header.getWidth(),
            translationY + header.getHeight());
}
 
开发者ID:sswukang,项目名称:RvAdapter,代码行数:29,代码来源:HeaderPositionCalculator.java

示例8: getMarginBottom

import android.view.ViewGroup; //导入方法依赖的package包/类
private int getMarginBottom(View v) {
    int marginBottom = 0;
    final ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
    if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
        marginBottom = ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
    }
    return marginBottom;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:ScrollAwareFABBehavior.java

示例9: setTranslucentForImageView

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 为头部是 ImageView 的界面设置状态栏透明
 *
 * @param activity       需要设置的activity
 * @param statusBarAlpha 状态栏透明度
 * @param needOffsetView 需要向下偏移的 View
 */
public static void setTranslucentForImageView(Activity activity, int statusBarAlpha, View needOffsetView) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    setTransparentForWindow(activity);
    addTranslucentView(activity, statusBarAlpha);
    if (needOffsetView != null) {
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
        layoutParams.setMargins(0, getStatusBarHeight(activity), 0, 0);
    }
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:19,代码来源:BarUtils.java

示例10: setOptionsVisible

import android.view.ViewGroup; //导入方法依赖的package包/类
private void setOptionsVisible(boolean visible) {

        isOptionsShow = visible;

        float y1 = -viewHolder.container.getHeight();
        float y2 = 0;

        View v = viewHolder.done;
        ViewGroup.MarginLayoutParams mp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
        int sh = Utils.getMetrics(this).heightPixels;
        float y3 = sh + v.getHeight() + mp.bottomMargin;
        float y4 = sh - v.getHeight() - mp.bottomMargin;

        float from, to;
        float from1, to1;
        if (visible) {
            from = y1;
            to = y2;

            from1 = y3;
            to1 = y4;
        } else {
            from = y2;
            to = y1;

            from1 = y4;
            to1 = y3;
        }

        int dur = 1000;
        AnimationUtils.startTranslateYAnim(from, to, dur, viewHolder.container, new DecelerateInterpolator());
        AnimationUtils.startTranslateYAnim(from1, to1, dur, v, new DecelerateInterpolator());


    }
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:36,代码来源:PlayThemeCustomActivity.java

示例11: generateLayoutParams

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
    if (lp instanceof ViewGroup.MarginLayoutParams) {
        return new LayoutParams((ViewGroup.MarginLayoutParams) lp);
    } else {
        return new LayoutParams(lp);
    }
}
 
开发者ID:JaylenHsieh,项目名称:Here,代码行数:9,代码来源:SpannedGridLayoutManager.java

示例12: getMarginEnd

import android.view.ViewGroup; //导入方法依赖的package包/类
static int getMarginEnd(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:8,代码来源:Utils.java

示例13: adjustChildren

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * Iterates over children and changes their width and height to one calculated from percentage
 * values.
 * @param widthMeasureSpec Width MeasureSpec of the parent ViewGroup.
 * @param heightMeasureSpec Height MeasureSpec of the parent ViewGroup.
 */
public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec) {
    if (DEBUG) {
        Log.d(TAG, "adjustChildren: " + mHost + " widthMeasureSpec: "
                + View.MeasureSpec.toString(widthMeasureSpec) + " heightMeasureSpec: "
                + View.MeasureSpec.toString(heightMeasureSpec));
    }

    // Calculate available space, accounting for host's paddings
    int widthHint = View.MeasureSpec.getSize(widthMeasureSpec) - mHost.getPaddingLeft()
            - mHost.getPaddingRight();
    int heightHint = View.MeasureSpec.getSize(heightMeasureSpec) - mHost.getPaddingTop()
            - mHost.getPaddingBottom();
    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 adjust " + view + " " + params);
        }
        if (params instanceof PercentLayoutParams) {
            PercentLayoutInfo info =
                    ((PercentLayoutParams) params).getPercentLayoutInfo();
            if (DEBUG) {
                Log.d(TAG, "using " + info);
            }
            if (info != null) {
                //支持字体大小百分比
                supportTextSize(widthHint,heightHint,view ,info);
                if (params instanceof ViewGroup.MarginLayoutParams) {
                    info.fillMarginLayoutParams(view, (ViewGroup.MarginLayoutParams) params,
                            widthHint, heightHint);
                }
                else {
                    info.fillLayoutParams(params, widthHint, heightHint);
                }
            }
        }
    }
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:45,代码来源:PercentLayoutHelper.java

示例14: getX

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 获取x坐标
 *
 * @return
 */
public int getX() {
    final View view = getView();
    if (view != null) {
        if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
            return ((ViewGroup.MarginLayoutParams) view.getLayoutParams()).leftMargin;
        } else {
            //TODO 其他Layout处理
        }
    }
    return 0;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:17,代码来源:UDView.java

示例15: getMeasuredWidthWithMargins

import android.view.ViewGroup; //导入方法依赖的package包/类
public static int getMeasuredWidthWithMargins(View child) {
    final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) child.getLayoutParams();
    return child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:MeasureUtils.java


注:本文中的android.view.ViewGroup.MarginLayoutParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。