getContext()); MenuWidth=ScreenWidth/4; HalfMenuWidth=MenuWidth/2; left.getLayoutParams...().width=MenuWidth; centre.getLayoutParams().width=ScreenWidth; right.getLayoutParams...我们首先拿到左菜单,内容,右菜单所对用的view,即left,centre,right这三个View,然后获取屏幕的宽度,动态设定菜单的宽度为屏幕宽度的四分之一,而内容的宽度就是整个屏幕的宽度,即 left.getLayoutParams...().width=MenuWidth; centre.getLayoutParams().width=ScreenWidth; right.getLayoutParams().width=MenuWidth
获取ViewGroup.LayoutParams getLayoutParams()方法可以获取ViewGroup.LayoutParams对象。...super(context, attrs, defStyle); setupView(context); } private void setupView(Context context) { if (getLayoutParams...findViewById(R.id.inner_layout); FrameLayout.LayoutParams par = (FrameLayout.LayoutParams) innerLayout.getLayoutParams...findViewById(R.id.inner_layout); LinearLayout.LayoutParams par = (LinearLayout.LayoutParams) innerLayout.getLayoutParams
ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams...: public static void setHeightParams(View view,int dp){ LayoutParams lp=(LayoutParams)view.getLayoutParams...public static void setWidthParams(View view,int dp){ LayoutParams lp=(LayoutParams)view.getLayoutParams...static void setLeftMarginParams(View view,int dp){ MarginLayoutParams lp=(MarginLayoutParams)view.getLayoutParams...static void setRightMarginParams(View view,int dp){ MarginLayoutParams lp=(MarginLayoutParams)view.getLayoutParams
outMetrics.heightPixels; 假设我当前是在A页面,我要分享出去的B图片和A页面只需要隐藏分享按钮,接下来提供第二种方法,这种方法的做法是: Bitmap b = Bitmap.createBitmap( v.getLayoutParams...().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); v.layout...* 创建分享Bitmap */ private Bitmap createBitmap() { //自定义ViewGroup,一定要手动调用测量,布局的方法 measure(getLayoutParams...().width, getLayoutParams().height); layout(0, 0, getMeasuredWidth(), getMeasuredHeight());
// noinspection unchecked 1900 AbsListView.LayoutParams p = (AbsListView.LayoutParams) child.getLayoutParams...1972 } 1973 我们看到 AbsListView.LayoutParams p = (AbsListView.LayoutParams) child.getLayoutParams() 一句正是...= null) { 2325 final LayoutParams params = (LayoutParams) transientView.getLayoutParams();...2273 2274 if (mAdapterHasStableIds) { 2275 final ViewGroup.LayoutParams vlp = child.getLayoutParams...r2/xref/frameworks/base/core/java/android/widget/AbsListView.java#mAdapterHasStableIds)) 那么我们的child的getLayoutParams
continue; } final LayoutParams lp = (LayoutParams) view.getLayoutParams(); if...continue; } final LayoutParams lp = (LayoutParams) view.getLayoutParams();...continue; } final LayoutParams lp = (LayoutParams) view.getLayoutParams(); if...continue; } final LayoutParams lp = (LayoutParams) view.getLayoutParams(); if...continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams();
dispatch continue; } final LayoutParams lp = (LayoutParams) view.getLayoutParams...continue; } final LayoutParams lp = (LayoutParams) view.getLayoutParams();...child = mDependencySortedChildren.get(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams...continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams();...onLayoutChild(View child, int layoutDirection) { final LayoutParams lp = (LayoutParams) child.getLayoutParams
Scroller(context); } //6、2 属性动画一定要实现该属性的set方法 public void setWidth(int width){ getLayoutParams...().width = width; requestLayout(); } public int getW(){ return getLayoutParams...layoutParams // ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams
LinearLayout.LayoutParams 代码如下: LinearLayout.LayoutParams layoutParams=(LinearLayout.LayoutParams)getLayoutParams...RelativeLayout.LayoutParams layoutParams=(RelativeLayout.LayoutParams)getLayoutParams(); layoutParams.leftMargin...ViewGroup.MarginLayoutParams来实现: ViewGroup.MarginLayoutParams layoutParams=(ViewGroup.MarginLayoutParams)getLayoutParams
ScreenUtil(this).getAppWidth(); float width = new ScreenUtil(this).getAppHeight(); mRlVv.getLayoutParams...().height = (int) width; mRlVv.getLayoutParams().width = (int) height; } else { /...ScreenUtil(this).getAppWidth(); float height = DisplayUtil.dp2px(this, 200.f); mRlVv.getLayoutParams...().height = (int) height; mRlVv.getLayoutParams().width = (int) width; } } 里面有几个uitl, 都是常见的封装
private final TextView name,selectedBar; public VH(View v) { super(v); v.getLayoutParams...().width = getActivity().getWindowManager().getDefaultDisplay().getWidth() / 4 + 30; v.getLayoutParams...().height = v.getLayoutParams().width / 2 ; name = (TextView) v.findViewById(R.id.main_goods_species_name
this.mTarget = mTarget; 9 } 10 11 12 public int getWidth() { 13 return mTarget.getLayoutParams...().width; 14 } 15 16 public void setWidth(int width) { 17 mTarget.getLayoutParams...animator.getAnimatedFraction(); 22 // 直接调用整型估值器通过比例计算出宽度,然后再设给Button 23 target.getLayoutParams
mHeaderHeight; int newWidth = (int) ((((float) newHeight / mHeaderHeight)) * mHeaderWidth); mHeaderView.getLayoutParams...().height = newHeight; mHeaderView.getLayoutParams().width = newWidth; int margin = (newWidth...如果觉得这样重置过程不够丝滑,可以通过动画来完成一个流畅的重置效果,这里就不演示了) /** * 重置头部 */ private void resetHeader() { mHeaderView.getLayoutParams...().height = mHeaderHeight; mHeaderView.getLayoutParams().width = mHeaderWidth; mHeaderView.setTranslationX
canvas.translate(-tranX, 0); super.onDraw(canvas); } 我们可以看到,文字也居中了: [1240] 最后再说一下收缩效果的实现方式 主要也是通过getLayoutParams...().width和getLayoutParams().height来改变布局的尺寸,在开始收缩时先将文本设置为空drawablePadding字符0,设为,然后再开始收缩动画,具体的方式可以自行尝试。...// b = getRootViewSize() // k = getRootViewSize() - getLoadingSize getLayoutParams...mRootViewSizeSaved[0]) * (float) animation.getAnimatedValue() + mRootViewSizeSaved[0]); getLayoutParams
super.onMeasure(widthMeasureSpec, heightMeasureSpec); LayoutParams params = (LayoutParams) getChildAt(1).getLayoutParams...并且向下滑动时,则不断的放大图片(通过改变ImageView)的高度 LayoutParams layoutParams = (LayoutParams) getChildAt(0) .getLayoutParams...(1).getTop() imageHeight) { LayoutParams layoutParams = (LayoutParams) getChildAt(0) .getLayoutParams...) animation.getAnimatedValue(); LayoutParams layoutParams = (LayoutParams) getChildAt(0) .getLayoutParams
super.onMeasure(widthMeasureSpec, heightMeasureSpec); LayoutParams params = (LayoutParams) getChildAt(1).getLayoutParams...通过改变ImageView)的高度 LayoutParams layoutParams = (LayoutParams) getChildAt(0) .getLayoutParams...imageHeight) { LayoutParams layoutParams = (LayoutParams) getChildAt(0) .getLayoutParams...animation.getAnimatedValue(); LayoutParams layoutParams = (LayoutParams) getChildAt(0) .getLayoutParams
R.drawable.button_selector); setGravity(Gravity.CENTER); setClickable(true); } } 在将布局添加到布局后,我从代码中设置了Button的宽度和高度: button.getLayoutParams...().width = myWidth; button.getLayoutParams().height = myHeight; button_selector.xml: android:drawable
(Integer) animator.getAnimatedValue(); // 根据比例更改目标view的宽度 view.getLayoutParams...最后,对象实际的宽度值为view.getLayoutParams().width。...this.maxWidth = maxWidth; } public int getWidth() { return target.getLayoutParams...public void setWidth(int widthValue) { //widthValue的值从100到20变化 target.getLayoutParams...().width; } public void setWidth(int widthValue) { target.getLayoutParams().
3] = (LinearLayout) view.findViewById(R.id.des_layout_4); LayoutParams layoutParams = safe_content.getLayoutParams...RelativeLayout.LayoutParams layoutParams = (android.widget.RelativeLayout.LayoutParams) safe_content.getLayoutParams...getMeasureHeight(){ int width = safe_content.getMeasuredWidth(); // 由于宽度不会发生变化 宽度的值取出来 safe_content.getLayoutParams...des_layout.setOnClickListener(this); //des_content 起始高度7行的高度 LayoutParams layoutParams = des_content.getLayoutParams...public int getLongMeasureHeight(){ int width=des_content.getMeasuredWidth(); // 开始宽度 des_content.getLayoutParams
view.setTag(VIEW_EMPTY); mViews.add(view); addViewInLayout(view, -1, view.getLayoutParams...view.setTag(VIEW_ERROR_DATA); mViews.add(view); addViewInLayout(view, -1, view.getLayoutParams...view.setTag(VIEW_ERROR_NET); mViews.add(view); addViewInLayout(view, -1, view.getLayoutParams...view.setTag(VIEW_LOADING); mViews.add(view); addViewInLayout(view, -1, view.getLayoutParams...view.setTag(state); view.setVisibility(GONE); addViewInLayout(view, -1, view.getLayoutParams
领取专属 10元无门槛券
手把手带您无忧上云