當前位置: 首頁>>代碼示例>>Java>>正文


Java View.requestLayout方法代碼示例

本文整理匯總了Java中android.view.View.requestLayout方法的典型用法代碼示例。如果您正苦於以下問題:Java View.requestLayout方法的具體用法?Java View.requestLayout怎麽用?Java View.requestLayout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.requestLayout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performCircularReveal

import android.view.View; //導入方法依賴的package包/類
private void performCircularReveal(View show) {
    show.setBackgroundColor(0xffff0000);
    ViewCompat.setTranslationY(show, 0);
    ViewCompat.setTranslationX(show, 0);
    show.getLayoutParams().height = 500;
    show.getLayoutParams().width = 1920;
    show.requestLayout();
    int centerX = (show.getLeft() + show.getRight()) / 2;
    int centerY = (show.getTop() + show.getBottom()) / 2;
    float finalRadius = (float) Math.hypot((double) centerX, (double) centerY);
    Animator mCircularReveal = ViewAnimationUtils.createCircularReveal(
            show, centerX, centerY, 0, finalRadius);
    mCircularReveal.setInterpolator(new AccelerateDecelerateInterpolator());
    mCircularReveal.setDuration(500);
    mCircularReveal.start();
}
 
開發者ID:teisun,項目名稱:SunmiUI,代碼行數:17,代碼來源:ImageSharedTransitionActivity.java

示例2: expand

import android.view.View; //導入方法依賴的package包/類
private void expand(final View v) {
    v.measure(-1, -2);
    final int targetHeight = v.getMeasuredHeight();
    v.getLayoutParams().height = 0;
    v.setVisibility(0);
    this.animation = new Animation() {
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1.0f) {
                ExpandableLayout.this.isOpened = Boolean.valueOf(true);
            }
            v.getLayoutParams().height = interpolatedTime == 1.0f ? -2 : (int) (((float)
                    targetHeight) * interpolatedTime);
            v.requestLayout();
        }

        public boolean willChangeBounds() {
            return true;
        }
    };
    this.animation.setDuration((long) this.duration.intValue());
    v.startAnimation(this.animation);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:ExpandableLayout.java

示例3: blueStreakOfProgress

import android.view.View; //導入方法依賴的package包/類
private void blueStreakOfProgress(Integer current, Integer max) {
	// Set up the progress bar
	if (mProgressWidth == 0) {
		final View vShareProgressEmpty = (View) findViewById(R.id.vShareProgressEmpty);
		mProgressWidth = vShareProgressEmpty.getMeasuredWidth();
	}
	// Display stuff
	if (max == 0)
		max = 1;
	int width = (int) ((float) mProgressWidth) * current / max;

	View vShareProgressFull = (View) findViewById(R.id.vShareProgressFull);
	vShareProgressFull.getLayoutParams().width = width;
	vShareProgressFull.invalidate();
	vShareProgressFull.requestLayout();
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:17,代碼來源:ActivityShare.java

示例4: refreshHeight

import android.view.View; //導入方法依賴的package包/類
public static boolean refreshHeight(final View view, final int aimHeight) {
    if (view.isInEditMode()) {
        return false;
    }

    if (view.getHeight() == aimHeight) {
        return false;
    }

    if (Math.abs(view.getHeight() - aimHeight) ==
            StatusBarHeightUtil.getStatusBarHeight(view.getContext())) {
        return false;
    }

    final int validPanelHeight = KeyboardManagerImpl.getValidPanelHeight(view.getContext());
    ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
    if (layoutParams == null) {
        layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                validPanelHeight);
        view.setLayoutParams(layoutParams);
    } else {
        layoutParams.height = validPanelHeight;
        view.requestLayout();
    }

    return true;
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:28,代碼來源:ViewUtil.java

示例5: instantiateItem

import android.view.View; //導入方法依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(mContext).inflate(R.layout.zoomable_view_pager_item, null);
    ZoomableDraweeView zoomableDraweeView = (ZoomableDraweeView) view.findViewById(R.id.zoomable_image);
    //允許縮放時切換
    zoomableDraweeView.setAllowTouchInterceptionWhileZoomed(true);
    //長按
    zoomableDraweeView.setIsLongpressEnabled(false);
    //雙擊擊放大或縮小
    zoomableDraweeView.setTapListener(new DoubleTapGestureListener(zoomableDraweeView));

    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setUri(mPaths.get(position))
            .build();
    //加載圖片
    zoomableDraweeView.setController(draweeController);
    container.addView(view);
    view.requestLayout();
    return view;
}
 
開發者ID:idisfkj,項目名稱:Zoomable,代碼行數:21,代碼來源:ZoomableViewPagerAdapter.java

示例6: setChildHeightForTableLayout

import android.view.View; //導入方法依賴的package包/類
public static void setChildHeightForTableLayout(View view, int height) {
  Object layoutParams = view.getLayoutParams();
  if (layoutParams instanceof TableRow.LayoutParams) {
    TableRow.LayoutParams tableLayoutParams = (TableRow.LayoutParams) layoutParams;
    switch (height) {
      case Component.LENGTH_PREFERRED:
        tableLayoutParams.height = TableRow.LayoutParams.WRAP_CONTENT;
        break;
      case Component.LENGTH_FILL_PARENT:
        tableLayoutParams.height = TableRow.LayoutParams.FILL_PARENT;
        break;
      default:
        tableLayoutParams.height = calculatePixels(view, height);
        break;
    }
    view.requestLayout();
  } else {
    Log.e("ViewUtil", "The view does not have table layout parameters");
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:21,代碼來源:ViewUtil.java

示例7: setChildWidthForVerticalLayout

import android.view.View; //導入方法依賴的package包/類
public static void setChildWidthForVerticalLayout(View view, int width) {
    // In a vertical layout, if a child's width is set to fill parent, we can simply set the
    // LayoutParams width to fill parent.
    Object layoutParams = view.getLayoutParams();
    if (layoutParams instanceof LinearLayout.LayoutParams) {
      LinearLayout.LayoutParams linearLayoutParams = (LinearLayout.LayoutParams) layoutParams;
      switch (width) {
        case Component.LENGTH_PREFERRED:
          linearLayoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
          break;
        case Component.LENGTH_FILL_PARENT:
          linearLayoutParams.width = LinearLayout.LayoutParams.FILL_PARENT;
          break;
        default:
          linearLayoutParams.width = calculatePixels(view, width);
          break;
      }
//      System.err.println("ViewUtil: setChildWidthForVerticalLayout: view = " + view + " width = " + width);
      view.requestLayout();
    } else {
      Log.e("ViewUtil", "The view does not have linear layout parameters");
    }
  }
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:24,代碼來源:ViewUtil.java

示例8: expand

import android.view.View; //導入方法依賴的package包/類
public static void expand(final View v) {
    v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    // Older versions of android (pre API 21) cancel animations for views with a height of 0.
    v.getLayoutParams().height = 1;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? ViewGroup.LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
開發者ID:manuelsc,項目名稱:Lunary-Ethereum-Wallet,代碼行數:27,代碼來源:CollapseAnimator.java

示例9: setChildWidthForHorizontalLayout

import android.view.View; //導入方法依賴的package包/類
public static void setChildWidthForHorizontalLayout(View view, int width) {
  // In a horizontal layout, if a child's width is set to fill parent, we must set the
  // LayoutParams width to 0 and the weight to 1. For other widths, we set the weight to 0
  Object layoutParams = view.getLayoutParams();
  if (layoutParams instanceof LinearLayout.LayoutParams) {
    LinearLayout.LayoutParams linearLayoutParams = (LinearLayout.LayoutParams) layoutParams;
    switch (width) {
      case Component.LENGTH_PREFERRED:
        linearLayoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
        linearLayoutParams.weight = 0;
        break;
      case Component.LENGTH_FILL_PARENT:
        linearLayoutParams.width = 0;
        linearLayoutParams.weight = 1;
        break;
      default:
        linearLayoutParams.width = calculatePixels(view, width);
        linearLayoutParams.weight = 0;
        break;
    }
    view.requestLayout();
  } else {
    Log.e("ViewUtil", "The view does not have linear layout parameters");
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:26,代碼來源:ViewUtil.java

示例10: onRecreateLabel

import android.view.View; //導入方法依賴的package包/類
@Override
public void onRecreateLabel(View tileView) {
    if (mScalingFactor != 1f) {
        updateLabelLayout(tileView);
        tileView.requestLayout();
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:8,代碼來源:BaseTile.java

示例11: setViewMargin

import android.view.View; //導入方法依賴的package包/類
/**
 * 設置某個View的margin
 *
 * @param view   需要設置的view
 * @param isDp   需要設置的數值是否為DP
 * @param left   左邊距
 * @param right  右邊距
 * @param top    上邊距
 * @param bottom 下邊距
 * @return
 */
public static ViewGroup.LayoutParams setViewMargin(View view, boolean isDp, int left, int right, int top, int bottom) {
    if (view == null) {
        return null;
    }

    int leftPx = left;
    int rightPx = right;
    int topPx = top;
    int bottomPx = bottom;
    ViewGroup.LayoutParams params = view.getLayoutParams();
    ViewGroup.MarginLayoutParams marginParams = null;
    //獲取view的margin設置參數
    if (params instanceof ViewGroup.MarginLayoutParams) {
        marginParams = (ViewGroup.MarginLayoutParams) params;
    } else {
        //不存在時創建一個新的參數
        marginParams = new ViewGroup.MarginLayoutParams(params);
    }

    //根據DP與PX轉換計算值
    if (isDp) {
        leftPx = dip2px(left);
        rightPx = dip2px(right);
        topPx = dip2px(top);
        bottomPx = dip2px(bottom);
    }
    //設置margin
    marginParams.setMargins(leftPx, topPx, rightPx, bottomPx);
    view.setLayoutParams(marginParams);
    view.requestLayout();
    return marginParams;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:44,代碼來源:DensityUtil.java

示例12: set

import android.view.View; //導入方法依賴的package包/類
@Override
public void set(View object, Integer value) {
  LayoutParams layoutParams;
  if (object != null && (layoutParams = object.getLayoutParams()) != null) {
    setProperty(layoutParams, value);
    if (object instanceof IRenderResult) {
      WXComponent component = ((IRenderResult) object).getComponent();
      if (component != null) {
          component.notifyNativeSizeChanged(layoutParams.width, layoutParams.height);
      }
    }
    object.requestLayout();
  }
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:15,代碼來源:LayoutParamsProperty.java

示例13: updateTabViewsLayoutParams

import android.view.View; //導入方法依賴的package包/類
private void updateTabViewsLayoutParams() {
for (int i = 0; i < mTabStrip.getChildCount(); i++) {
  View child = mTabStrip.getChildAt(i);
  updateTabViewLayoutParams((LinearLayout.LayoutParams) child.getLayoutParams());
  child.requestLayout();
}
 }
 
開發者ID:TIIEHenry,項目名稱:TIIEHenry-Android-SDK,代碼行數:8,代碼來源:TabLayout.java

示例14: performResizeAction

import android.view.View; //導入方法依賴的package包/類
@Thunk void performResizeAction(int action, View host, LauncherAppWidgetInfo info) {
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) host.getLayoutParams();
    CellLayout layout = (CellLayout) host.getParent().getParent();
    layout.markCellsAsUnoccupiedForView(host);

    if (action == R.string.action_increase_width) {
        if (((host.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL)
                && layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY))
                || !layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY)) {
            lp.cellX --;
            info.cellX --;
        }
        lp.cellHSpan ++;
        info.spanX ++;
    } else if (action == R.string.action_decrease_width) {
        lp.cellHSpan --;
        info.spanX --;
    } else if (action == R.string.action_increase_height) {
        if (!layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1)) {
            lp.cellY --;
            info.cellY --;
        }
        lp.cellVSpan ++;
        info.spanY ++;
    } else if (action == R.string.action_decrease_height) {
        lp.cellVSpan --;
        info.spanY --;
    }

    layout.markCellsAsOccupiedForView(host);
    Rect sizeRange = new Rect();
    AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, sizeRange);
    ((LauncherAppWidgetHostView) host).updateAppWidgetSize(null,
            sizeRange.left, sizeRange.top, sizeRange.right, sizeRange.bottom);
    host.requestLayout();
    LauncherModel.updateItemInDatabase(mLauncher, info);
    announceConfirmation(mLauncher.getString(R.string.widget_resized, info.spanX, info.spanY));
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:39,代碼來源:LauncherAccessibilityDelegate.java

示例15: setWidth

import android.view.View; //導入方法依賴的package包/類
/**
 * Helps to force width value before calling requestLayout by the system.
 */
public static void setWidth(View p_jView, int p_nWidth) {
    // Change width value from params
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) p_jView.getLayoutParams();
    params.width = p_nWidth;
    p_jView.setLayoutParams(params);

    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(p_nWidth, View.MeasureSpec.EXACTLY);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(p_jView.getMeasuredHeight(),
            View.MeasureSpec.EXACTLY);
    p_jView.measure(widthMeasureSpec, heightMeasureSpec);

    p_jView.requestLayout();
}
 
開發者ID:evrencoskun,項目名稱:TableView,代碼行數:17,代碼來源:TableViewUtils.java


注:本文中的android.view.View.requestLayout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。