当前位置: 首页>>代码示例>>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;未经允许,请勿转载。