當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。