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


Java View.getLayoutParams方法代码示例

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


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

示例1: offsetY

import android.view.View; //导入方法依赖的package包/类
protected int offsetY(View child, boolean centreInVisibleBounds, boolean marginInclude) {
    int current;
    MarginLayoutParams marginLp = (marginInclude && child.getLayoutParams() instanceof MarginLayoutParams) ? (MarginLayoutParams) child.getLayoutParams() : null;
    if (centreInVisibleBounds) {
        current = (child.getTop() + child.getBottom()) >> 1;
        if (marginLp != null) {
            current = current + (marginLp.bottomMargin - marginLp.topMargin) / 2;
        }
        return current - mVisibleBounds.centerY() + mVisibleBounds.top - getPaddingTop();
    } else {
        current = child.getTop();
        if (marginLp != null) {
            current = current - marginLp.topMargin;
        }
        return current - getPaddingTop();
    }
}
 
开发者ID:rexyren,项目名称:PageScrollView,代码行数:18,代码来源:BaseViewGroup.java

示例2: measureView

import android.view.View; //导入方法依赖的package包/类
public static void measureView(View child) {
    ViewGroup.LayoutParams p = child.getLayoutParams();
    if (p == null) {
        p = new ViewGroup.LayoutParams(-1, -2);
    }

    int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0, p.width);
    int lpHeight = p.height;
    int childHeightSpec;
    if (lpHeight > 0) {
        childHeightSpec = View.MeasureSpec.makeMeasureSpec(lpHeight, 1073741824);
    } else {
        childHeightSpec = View.MeasureSpec.makeMeasureSpec(0, 0);
    }

    child.measure(childWidthSpec, childHeightSpec);
}
 
开发者ID:Tamicer,项目名称:FilterBar,代码行数:18,代码来源:UIUtil.java

示例3: measureScrapChild

import android.view.View; //导入方法依赖的package包/类
private void measureScrapChild(View child, int position, int widthMeasureSpec) {
    LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        p = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0);
        child.setLayoutParams(p);
    }
    p.viewType = mAdapter.getItemViewType(position);
    p.forceAdd = true;

    int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
            mListPadding.left + mListPadding.right, 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:Shmilyz,项目名称:Swap,代码行数:22,代码来源:PLA_ListView.java

示例4: nextViewFromScrapList

import android.view.View; //导入方法依赖的package包/类
/**
 * Returns the next item from the scrap list.
 * <p>
 * Upon finding a valid VH, sets current item position to VH.itemPosition + mItemDirection
 *
 * @return View if an item in the current position or direction exists if not null.
 */
private View nextViewFromScrapList() {
    final int size = mScrapList.size();
    for (int i = 0; i < size; i++) {
        final View view = mScrapList.get(i).itemView;
        final LayoutParams lp = (LayoutParams) view.getLayoutParams();
        if (lp.isItemRemoved()) {
            continue;
        }
        if (mCurrentPosition == lp.getViewLayoutPosition()) {
            assignPositionFromScrapList(view);
            return view;
        }
    }
    return null;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:23,代码来源:LinearLayoutManager.java

示例5: drawVertical

import android.view.View; //导入方法依赖的package包/类
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        android.support.v7.widget.RecyclerView v = new android.support.v7.widget.RecyclerView(parent.getContext());
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
开发者ID:OCNYang,项目名称:RecyclerViewEvent,代码行数:17,代码来源:DividerListItemDecoration.java

示例6: onLayout

import android.view.View; //导入方法依赖的package包/类
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int count = getChildCount();
    int parentLeft = getPaddingLeft();
    int parentRight = (right - left) - getPaddingRight();
    int parentTop = getPaddingTop();
    int parentBottom = (bottom - top) - getPaddingBottom();
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        if (child.getVisibility() != 8) {
            LayoutParams lp = (LayoutParams) child.getLayoutParams();
            int childLeft = parentLeft + lp.leftMargin;
            int childTop = parentTop + lp.topMargin;
            child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight());
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:ActionBarOverlayLayout.java

示例7: onLayout

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
  int count = getChildCount();
  mWidth = getMeasuredWidth();
  mHeight = getMeasuredHeight();
  for (int i = 0; i < count; i++) {
    View child = getChildAt(i);
    if (child.getVisibility() != GONE) {
      LayoutParams lp = (LayoutParams) child.getLayoutParams();
      int childLeft = mPaddingLeft + lp.x;
      if (lp.width > 0)
        childLeft += (int) ((mWidth - lp.width) / 2.0);
      else
        childLeft += (int) ((mWidth - child.getMeasuredWidth()) / 2.0);
      int childTop = mPaddingTop + lp.y;
      if (lp.height > 0)
        childTop += (int) ((mHeight - lp.height) / 2.0);
      else
        childTop += (int) ((mHeight - child.getMeasuredHeight()) / 2.0);
      child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight());
    }
  }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:24,代码来源:CenterLayout.java

示例8: getMarginStart

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

示例9: drawHorizontal

import android.view.View; //导入方法依赖的package包/类
public void drawHorizontal(Canvas c, RecyclerView parent) {
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getLeft() - params.leftMargin;
        final int right = child.getRight() + params.rightMargin
                + mDivider.getIntrinsicWidth();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:16,代码来源:SupportGridItemDecoration.java

示例10: drawVerticalDivider

import android.view.View; //导入方法依赖的package包/类
private void drawVerticalDivider(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicWidth();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:16,代码来源:DividerListItemDecoration.java

示例11: expand

import android.view.View; //导入方法依赖的package包/类
/**
 * Expand a hidden view
 * @param v - current view
 */
private static void expand(final View v) {
    v.measure(CoordinatorLayout.LayoutParams.MATCH_PARENT, CoordinatorLayout.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();
    Animation anim = new Animation() {
        /**
         * Transform a view
         * @param interpolatedTime - time to transition
         * @param t - transition to apply
         */
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? CoordinatorLayout.LayoutParams.WRAP_CONTENT
                    : (int)(targetHeight * interpolatedTime);
            v.requestLayout();
        }

        /**
         * Returns if the bounds will change
         * @return Returns true
         */
        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };
    // 3dp/ms
    anim.setDuration(((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density)) * 3);
    v.startAnimation(anim);
}
 
开发者ID:iskandergaba,项目名称:Botanist,代码行数:35,代码来源:PlantActivity.java

示例12: setViewMargin

import android.view.View; //导入方法依赖的package包/类
public ViewGroup.MarginLayoutParams setViewMargin(View view, int left, int top, int right, int bottom) {
    if (view == null) {
        return null;
    }
    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
    if (lp != null) {
        lp.setMargins(left, top, right, bottom);
        view.setLayoutParams(lp);
    }
    return lp;
}
 
开发者ID:AriesHoo,项目名称:UIWidget,代码行数:12,代码来源:UIActionSheetView.java

示例13: isDrawerOpen

import android.view.View; //导入方法依赖的package包/类
public boolean isDrawerOpen(View drawer) {
    if (!isDrawerView(drawer)) {
        throw new IllegalArgumentException("View " + drawer + " is not a drawer");
    } else if ((((LayoutParams) drawer.getLayoutParams()).openState & 1) == 1) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:DrawerLayout.java

示例14: onDrawOver

import android.view.View; //导入方法依赖的package包/类
/**
 * @param c
 * @param parent
 * @param state
 */
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (dividerDrawable == null) {
        return;
    }

    int childCount = parent.getChildCount();
    int rightV = parent.getWidth();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

        int leftV = parent.getPaddingLeft() + child.getPaddingLeft();
        int bottomV = child.getTop() - params.topMargin;
        int topV = bottomV - dividerDrawable.getIntrinsicHeight();

        int topH = child.getTop() + params.topMargin;
        int bottomH = child.getBottom() + params.bottomMargin;
        int rightH = child.getLeft() - params.leftMargin;
        int leftH = rightH - dividerDrawable.getIntrinsicWidth();
        dividerDrawable.setBounds(leftH, topH, rightH, bottomH);
        dividerDrawable.draw(c);
        dividerDrawable.setBounds(leftV, topV, rightV, bottomV);
        dividerDrawable.draw(c);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:GridItemDecoration.java

示例15: addMarginTopToContentChild

import android.view.View; //导入方法依赖的package包/类
/**
 * add marginTop to simulate set FitsSystemWindow true
 */
private static void addMarginTopToContentChild(View mContentChild, int statusBarHeight) {
	if (mContentChild == null) {
		return;
	}
	if (!TAG_MARGIN_ADDED.equals(mContentChild.getTag())) {
		FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mContentChild.getLayoutParams();
		lp.topMargin += statusBarHeight;
		mContentChild.setLayoutParams(lp);
		mContentChild.setTag(TAG_MARGIN_ADDED);
	}
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:15,代码来源:StatusBarCompatKitKat.java


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