Java 类android.view.ViewGroup.MarginLayoutParams 实例源码

项目:chromium-for-android-56-debug-video    文件:SnackbarView.java   
void adjustViewPosition() {
    mParent.getWindowVisibleDisplayFrame(mCurrentVisibleRect);
    // Only update if the visible frame has changed, otherwise there will be a layout loop.
    if (!mCurrentVisibleRect.equals(mPreviousVisibleRect)) {
        mPreviousVisibleRect.set(mCurrentVisibleRect);

        int keyboardHeight = mParent.getHeight() - mCurrentVisibleRect.bottom
                + mCurrentVisibleRect.top;
        MarginLayoutParams lp = getLayoutParams();
        lp.bottomMargin = keyboardHeight;
        if (mIsTablet) {
            int margin = mParent.getResources()
                    .getDimensionPixelSize(R.dimen.snackbar_margin_tablet);
            ApiCompatibilityUtils.setMarginStart(lp, margin);
            lp.bottomMargin += margin;
            int width = mParent.getResources()
                    .getDimensionPixelSize(R.dimen.snackbar_width_tablet);
            lp.width = Math.min(width, mParent.getWidth() - 2 * margin);
        }
        mView.setLayoutParams(lp);
    }
}
项目:letv    文件:MyRandomSeeFragment.java   
private void findView() {
    this.mOperationBarView = this.root.findViewById(2131362660);
    this.mFooterLayout = UIs.inflate(this.mActivity, R.layout.fragment_my_download_worldcup_bottom, null);
    this.mFootCloseBtn = (Button) this.mFooterLayout.findViewById(R.id.btn_close_worldcup);
    this.mNullScrollView = (ScrollView) this.root.findViewById(R.id.scrollview_tip);
    this.mNullTip = (LinearLayout) this.root.findViewById(R.id.linearlayout_tip_download);
    this.mTextOpenTip = (TextView) this.root.findViewById(R.id.textv_open_worldcup_tip);
    ((MarginLayoutParams) this.mTextOpenTip.getLayoutParams()).topMargin = UIs.zoomWidth(LiveType.PLAY_LIVE_OTHER);
    this.mTextOpenSubTip = (TextView) this.root.findViewById(R.id.textv_open_worldcup_tip_line2);
    ((MarginLayoutParams) this.mTextOpenSubTip.getLayoutParams()).topMargin = UIs.zoomWidth(9);
    this.mListView = (ListView) this.root.findViewById(2131361938);
    this.mStartAllBtn = (Button) this.mOperationBarView.findViewById(2131362659);
    this.mPauseAllBtn = (Button) this.mOperationBarView.findViewById(2131362658);
    this.mOpenWorldCupBtn = (Button) this.root.findViewById(R.id.btn_open_close);
    this.mStartAllBtn.setOnClickListener(this.onClick);
    this.mPauseAllBtn.setOnClickListener(this.onClick);
    this.mOpenWorldCupBtn.setOnClickListener(this.onClick);
    this.mFootCloseBtn.setOnClickListener(this.onClick);
    this.mDialog = new CustomLoadingDialog(this.mActivity);
    this.mDialog.setCanceledOnTouchOutside(false);
    this.rootWatchAlertLayout = (RelativeLayout) this.root.findViewById(R.id.road_watch_ball_alert_layout);
    ((TextView) this.rootWatchAlertLayout.findViewById(R.id.road_watch_ball_alert)).setText(LetvTools.getTextFromServer(DialogMsgConstantId.CONSTANT_70013, getActivity().getResources().getString(2131100080)));
    this.rootWatchAlertLayout.setOnClickListener(this.onClick);
    setText();
}
项目:newIPlay    文件:FixedViewUtil.java   
public static void setGridViewHeightBasedOnChildren(GridView listView,int col) {
    // 获取listview的adapter
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter == null) {
        return;
    }
    // 固定列宽,有多少列
    int totalHeight = 0;
    // i每次加4,相当于listAdapter.getCount()小于等于4时 循环一次,计算一次item的高度,
    // listAdapter.getCount()小于等于8时计算两次高度相加
    for (int i = 0; i < listAdapter.getCount(); i += col) {
        // 获取listview的每一个item
        View listItem = listAdapter.getView(i, null, listView);
        listItem.measure(0, 0);
        // 获取item的高度和
        totalHeight += listItem.getMeasuredHeight();
        totalHeight += listView.getVerticalSpacing();
        if (i==listAdapter.getCount()-1) {
            totalHeight += listView.getVerticalSpacing();
        }
    }
    // 获取listview的布局参数
    LayoutParams params = listView.getLayoutParams();
    // 设置高度
    params.height = totalHeight;
    // 设置margin
    ((MarginLayoutParams) params).setMargins(10, 10, 10, 10);
    // 设置参数
    listView.setLayoutParams(params);
}
项目:simple-keyboard    文件:ViewLayoutUtils.java   
public static void placeViewAt(final View view, final int x, final int y, final int w,
        final int h) {
    final ViewGroup.LayoutParams lp = view.getLayoutParams();
    if (lp instanceof MarginLayoutParams) {
        final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp;
        marginLayoutParams.width = w;
        marginLayoutParams.height = h;
        marginLayoutParams.setMargins(x, y, -50, 0);
    }
}
项目:chromium-net-for-android    文件:ApiCompatibilityUtils.java   
/**
 * @see android.view.ViewGroup.MarginLayoutParams#setMarginEnd(int)
 */
public static void setMarginEnd(MarginLayoutParams layoutParams, int end) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        layoutParams.setMarginEnd(end);
    } else {
        layoutParams.rightMargin = end;
    }
}
项目:chromium-net-for-android    文件:ApiCompatibilityUtils.java   
/**
 * @see android.view.ViewGroup.MarginLayoutParams#getMarginStart()
 */
public static int getMarginStart(MarginLayoutParams layoutParams) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return layoutParams.getMarginStart();
    } else {
        return layoutParams.leftMargin;
    }
}
项目:Virtualview-Android    文件:ContainerService.java   
public View getContainer(String viewType, int containerType, boolean createParam) {
    IContainer container = null;

    ViewBase vb = mVM.getView(viewType);
    if (null == vb) {
        vb = mVM.getDefaultImage();
        vb.setViewType(viewType);
    }

    if (vb.isContainer()) {
        container = (IContainer) vb.getNativeView();
    } else {
        ContainerMrg cm = mContainerMrg.get(containerType);
        if (null != cm) {
            container = cm.getContainer(mAppContext);
        } else {
            Log.e(TAG, "getContainer type invalidate:" + containerType);
        }
    }

    if (null != container) {
        container.setVirtualView(vb);
        if (createParam) {
            Layout.Params p = vb.getComLayoutParams();
            MarginLayoutParams marginLayoutParams = new MarginLayoutParams(p.mLayoutWidth, p.mLayoutHeight);
            marginLayoutParams.leftMargin = p.mLayoutMarginLeft;
            marginLayoutParams.topMargin = p.mLayoutMarginTop;
            marginLayoutParams.rightMargin = p.mLayoutMarginRight;
            marginLayoutParams.bottomMargin = p.mLayoutMarginBottom;
            ((View)container).setLayoutParams(marginLayoutParams);
        }

        container.attachViews();
    }
    return (View)container;
}
项目:chromium-for-android-56-debug-video    文件:StripLayoutHelper.java   
/**
 * Displays the tab menu below the anchor tab.
 * @param anchorTab The tab the menu will be anchored to
 */
private void showTabMenu(StripLayoutTab anchorTab) {
    // 1. Bring the anchor tab to the foreground.
    int tabIndex = TabModelUtils.getTabIndexById(mModel, anchorTab.getId());
    TabModelUtils.setIndex(mModel, tabIndex);

    // 2. Anchor the popupMenu to the view associated with the tab
    View tabView = TabModelUtils.getCurrentTab(mModel).getView();
    mTabMenu.setAnchorView(tabView);

    // 3. Set the vertical offset to align the tab menu with bottom of the tab strip
    int verticalOffset =
            -(tabView.getHeight()
                    - (int) mContext.getResources().getDimension(R.dimen.tab_strip_height))
            - ((MarginLayoutParams) tabView.getLayoutParams()).topMargin;
    mTabMenu.setVerticalOffset(verticalOffset);

    // 4. Set the horizontal offset to align the tab menu with the right side of the tab
    int horizontalOffset = Math.round((anchorTab.getDrawX() + anchorTab.getWidth())
                                   * mContext.getResources().getDisplayMetrics().density)
            - mTabMenu.getWidth()
            - ((MarginLayoutParams) tabView.getLayoutParams()).leftMargin;
    // Cap the horizontal offset so that the tab menu doesn't get drawn off screen.
    horizontalOffset = Math.max(horizontalOffset, 0);
    mTabMenu.setHorizontalOffset(horizontalOffset);

    mTabMenu.show();
}
项目:YCWeather    文件:ViewUtil.java   
public static void setAbsListViewHeight(AbsListView absListView, int lineNumber, int verticalSpace) {
    int totalHeight = getAbsListViewHeight(absListView, lineNumber, verticalSpace);
    ViewGroup.LayoutParams params = absListView.getLayoutParams();
    params.height = totalHeight;
    ((MarginLayoutParams) params).setMargins(0, 0, 0, 0);
    absListView.setLayoutParams(params);
}
项目:chromium-for-android-56-debug-video    文件:MarginResizer.java   
private void updateMargins() {
    MarginLayoutParams layoutParams = (MarginLayoutParams) mView.getLayoutParams();
    if (mCurrentDisplayStyle == UiConfig.DISPLAY_STYLE_WIDE) {
        layoutParams.setMargins(mWideMarginSizePixels, layoutParams.topMargin,
                mWideMarginSizePixels, layoutParams.bottomMargin);
    } else {
        layoutParams.setMargins(mDefaultMarginSizePixels, layoutParams.topMargin,
                mDefaultMarginSizePixels, layoutParams.bottomMargin);
    }
}
项目:letv    文件:RecyclerView.java   
public LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams lp) {
    if (lp instanceof LayoutParams) {
        return new LayoutParams((LayoutParams) lp);
    }
    if (lp instanceof MarginLayoutParams) {
        return new LayoutParams((MarginLayoutParams) lp);
    }
    return new LayoutParams(lp);
}
项目:AOSP-Kayboard-7.1.2    文件:ViewLayoutUtils.java   
public static MarginLayoutParams newLayoutParam(final ViewGroup placer, final int width,
        final int height) {
    if (placer instanceof FrameLayout) {
        return new FrameLayout.LayoutParams(width, height);
    } else if (placer instanceof RelativeLayout) {
        return new RelativeLayout.LayoutParams(width, height);
    } else if (placer == null) {
        throw new NullPointerException("placer is null");
    } else {
        throw new IllegalArgumentException("placer is neither FrameLayout nor RelativeLayout: "
                + placer.getClass().getName());
    }
}
项目:boohee_v5.6    文件:TabLayout.java   
private void updateTextAndIcon(@Nullable TextView textView, @Nullable ImageView iconView) {
    Drawable icon;
    CharSequence text;
    CharSequence contentDesc;
    boolean hasText;
    if (this.mTab != null) {
        icon = this.mTab.getIcon();
    } else {
        icon = null;
    }
    if (this.mTab != null) {
        text = this.mTab.getText();
    } else {
        text = null;
    }
    if (this.mTab != null) {
        contentDesc = this.mTab.getContentDescription();
    } else {
        contentDesc = null;
    }
    if (iconView != null) {
        if (icon != null) {
            iconView.setImageDrawable(icon);
            iconView.setVisibility(0);
            setVisibility(0);
        } else {
            iconView.setVisibility(8);
            iconView.setImageDrawable(null);
        }
        iconView.setContentDescription(contentDesc);
    }
    if (TextUtils.isEmpty(text)) {
        hasText = false;
    } else {
        hasText = true;
    }
    if (textView != null) {
        if (hasText) {
            textView.setText(text);
            textView.setVisibility(0);
            setVisibility(0);
        } else {
            textView.setVisibility(8);
            textView.setText(null);
        }
        textView.setContentDescription(contentDesc);
    }
    if (iconView != null) {
        MarginLayoutParams lp = (MarginLayoutParams) iconView.getLayoutParams();
        int bottomMargin = 0;
        if (hasText && iconView.getVisibility() == 0) {
            bottomMargin = TabLayout.this.dpToPx(8);
        }
        if (bottomMargin != lp.bottomMargin) {
            lp.bottomMargin = bottomMargin;
            iconView.requestLayout();
        }
    }
    if (hasText || TextUtils.isEmpty(contentDesc)) {
        setOnLongClickListener(null);
        setLongClickable(false);
        return;
    }
    setOnLongClickListener(this);
}
项目:boohee_v5.6    文件:DrawerLayoutCompatApi21.java   
public static void applyMarginInsets(MarginLayoutParams lp, Object insets, int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == 3) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == 5) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public static int getLayoutDirection(MarginLayoutParams lp) {
    int result = IMPL.getLayoutDirection(lp);
    if (result == 0 || result == 1) {
        return result;
    }
    return 0;
}
项目:GravityBox    文件:ProgressBarView.java   
private void updatePosition() {
    if (mMode == Mode.OFF) return;

    MarginLayoutParams lp = null;
    if (mContainerType == ContainerType.STATUSBAR) {
        lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                mHeightPx);
        ((FrameLayout.LayoutParams)lp).gravity = mMode == Mode.TOP ? 
                Gravity.TOP : Gravity.BOTTOM;
    } else if (mContainerType == ContainerType.KEYGUARD) {
        lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                mHeightPx);
        if (mMode == Mode.TOP) {
            ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_TOP,
                    RelativeLayout.TRUE);
        } else {
            ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,
                    RelativeLayout.TRUE);
        }
    }

    if (lp != null) {
        lp.setMargins(0, mMode == Mode.TOP ? mEdgeMarginPx : 0,
                      0, mMode == Mode.BOTTOM ? mEdgeMarginPx : 0);
        setLayoutParams(lp);
    }
}
项目:ConstraintLayoutOverlap    文件:OverlappingDetector.java   
private static int bottomWithMargin(@NonNull View view) {
    int safeBottom = view.getBottom();
    if (view.getLayoutParams() instanceof MarginLayoutParams) {
        safeBottom += ((MarginLayoutParams) view.getLayoutParams()).bottomMargin;
    }
    return safeBottom;
}
项目:boohee_v5.6    文件:CollapsingToolbarLayout.java   
private static int getHeightWithMargins(@NonNull View view) {
    android.view.ViewGroup.LayoutParams lp = view.getLayoutParams();
    if (!(lp instanceof MarginLayoutParams)) {
        return view.getHeight();
    }
    MarginLayoutParams mlp = (MarginLayoutParams) lp;
    return (view.getHeight() + mlp.topMargin) + mlp.bottomMargin;
}
项目:boohee_v5.6    文件:AnimCheckBox.java   
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);
    if (MeasureSpec.getMode(widthMeasureSpec) == Integer.MIN_VALUE && MeasureSpec.getMode
            (heightMeasureSpec) == Integer.MIN_VALUE) {
        MarginLayoutParams params = (MarginLayoutParams) getLayoutParams();
        height = Math.min((dip(40) - params.leftMargin) - params.rightMargin, (dip(40) -
                params.bottomMargin) - params.topMargin);
        width = height;
    }
    int size = Math.min((width - getPaddingLeft()) - getPaddingRight(), (height -
            getPaddingBottom()) - getPaddingTop());
    setMeasuredDimension(size, size);
}
项目:boohee_v5.6    文件:RecyclerView.java   
public LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams lp) {
    if (lp instanceof LayoutParams) {
        return new LayoutParams((LayoutParams) lp);
    }
    if (lp instanceof MarginLayoutParams) {
        return new LayoutParams((MarginLayoutParams) lp);
    }
    return new LayoutParams(lp);
}
项目:boohee_v5.6    文件:Toolbar.java   
private void measureChildConstrained(View child, int parentWidthSpec, int widthUsed, int parentHeightSpec, int heightUsed, int heightConstraint) {
    MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
    int childWidthSpec = getChildMeasureSpec(parentWidthSpec, (((getPaddingLeft() + getPaddingRight()) + lp.leftMargin) + lp.rightMargin) + widthUsed, lp.width);
    int childHeightSpec = getChildMeasureSpec(parentHeightSpec, (((getPaddingTop() + getPaddingBottom()) + lp.topMargin) + lp.bottomMargin) + heightUsed, lp.height);
    int childHeightMode = MeasureSpec.getMode(childHeightSpec);
    if (childHeightMode != 1073741824 && heightConstraint >= 0) {
        childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightMode != 0 ? Math.min(MeasureSpec.getSize(childHeightSpec), heightConstraint) : heightConstraint, 1073741824);
    }
    child.measure(childWidthSpec, childHeightSpec);
}
项目:boohee_v5.6    文件:Toolbar.java   
private int measureChildCollapseMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed, int[] collapsingMargins) {
    MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
    int leftDiff = lp.leftMargin - collapsingMargins[0];
    int rightDiff = lp.rightMargin - collapsingMargins[1];
    int hMargins = Math.max(0, leftDiff) + Math.max(0, rightDiff);
    collapsingMargins[0] = Math.max(0, -leftDiff);
    collapsingMargins[1] = Math.max(0, -rightDiff);
    child.measure(getChildMeasureSpec(parentWidthMeasureSpec, ((getPaddingLeft() + getPaddingRight()) + hMargins) + widthUsed, lp.width), getChildMeasureSpec(parentHeightMeasureSpec, (((getPaddingTop() + getPaddingBottom()) + lp.topMargin) + lp.bottomMargin) + heightUsed, lp.height));
    return child.getMeasuredWidth() + hMargins;
}
项目:boohee_v5.6    文件:MarginLayoutParamsCompat.java   
public static int getLayoutDirection(MarginLayoutParams lp) {
    int result = IMPL.getLayoutDirection(lp);
    if (result == 0 || result == 1) {
        return result;
    }
    return 0;
}
项目:boohee_v5.6    文件:MarginLayoutParamsCompat.java   
public int getMarginEnd(MarginLayoutParams lp) {
    return lp.rightMargin;
}
项目:boohee_v5.6    文件:MarginLayoutParamsCompat.java   
public void setLayoutDirection(MarginLayoutParams lp, int layoutDirection) {
}
项目:boohee_v5.6    文件:DrawerLayout.java   
public void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity) {
}
项目:letv    文件:RecyclerView.java   
public LayoutParams(MarginLayoutParams source) {
    super(source);
}
项目:letv    文件:GridLayoutManager.java   
public LayoutParams(MarginLayoutParams source) {
    super(source);
}
项目:letv    文件:GridLayoutManager.java   
public android.support.v7.widget.RecyclerView.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams lp) {
    if (lp instanceof MarginLayoutParams) {
        return new LayoutParams((MarginLayoutParams) lp);
    }
    return new LayoutParams(lp);
}
项目:letv    文件:StaggeredGridLayoutManager.java   
public LayoutParams(MarginLayoutParams source) {
    super(source);
}
项目:letv    文件:StaggeredGridLayoutManager.java   
public android.support.v7.widget.RecyclerView.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams lp) {
    if (lp instanceof MarginLayoutParams) {
        return new LayoutParams((MarginLayoutParams) lp);
    }
    return new LayoutParams(lp);
}
项目:boohee_v5.6    文件:MarginLayoutParamsCompat.java   
public void resolveLayoutDirection(MarginLayoutParams lp, int layoutDirection) {
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public int getMarginEnd(MarginLayoutParams lp) {
    return lp.rightMargin;
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public void setMarginStart(MarginLayoutParams lp, int marginStart) {
    lp.leftMargin = marginStart;
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public void setMarginEnd(MarginLayoutParams lp, int marginEnd) {
    lp.rightMargin = marginEnd;
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public boolean isMarginRelative(MarginLayoutParams lp) {
    return false;
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public int getLayoutDirection(MarginLayoutParams lp) {
    return 0;
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public void setLayoutDirection(MarginLayoutParams lp, int layoutDirection) {
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public void resolveLayoutDirection(MarginLayoutParams lp, int layoutDirection) {
}
项目:letv    文件:MarginLayoutParamsCompat.java   
public int getMarginStart(MarginLayoutParams lp) {
    return MarginLayoutParamsCompatJellybeanMr1.getMarginStart(lp);
}