`

getLayoutParams

阅读更多
利用getLayoutParams()方法和setLayoutParams()方法。
三步曲:
1、首先利用getLayoutParams()方法,获取控件的LayoutParams。
eg:LayoutParams laParams=(LayoutParams)imageView.getLayoutParams();
2、设置该控件的layoutParams参数
eg:     laParams.height=200;
        laParams.width=100;
3、将修改好的layoutParams设置为该控件的layoutParams.
eg:imageView.setLayoutParams(laParams);

http://blog.sina.com.cn/s/blog_6b1079f10100nvsc.html
分享到:
评论

相关推荐

    android 3D相册效果

    final int imageHeight = child.getLayoutParams().height; final int imageWidth = child.getLayoutParams().width; final int rotation = Math.abs(rotationAngle); mCamera.translate(0.0f, 0.0f, 100.0f); ...

    GridView左右滑动

    //curPage.getLayoutParams().height = this.getWindowManager().getDefaultDisplay().getHeight() * 2 / 3; for (int i = 0; i ; i++) { //此处动态引用图片资源 info.setImage(R.drawable.g1); //设置图片...

    谷歌开源的Android排版库 FlexboxLayout.zip

    FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) view.getLayoutParams(); lp.order = -1; lp.flexGrow = 2; view.setLayoutParams(lp);屏幕截图: 标签:谷歌 google 排版库

    android.service.java

    params = SingleLayoutParams.getLayoutParams(); View lay = LayoutInflater.from(this).inflate(R.layout.mylinearlayout, null);// 讲xml问价解析为视图对象 merchant = (TextView) lay.findViewById(R...

    Android组件ConverFlow(继承Gallery)

    final int imageHeight = child.getLayoutParams().height; final int imageWidth = child.getLayoutParams().width; final int rotation = Math.abs(rotationAngle); // 在Z轴上正向移动camera的视角,实际...

    android 可移动控件

    // .getLayoutParams(); if(X - _xDelta){ lParams.leftMargin = 0- width/2; }else if(X -_xDelta> screenWidth - width/2){ lParams.leftMargin = screenWidth - width/2; }else{ lParams.leftMargin =...

    RenRenSlideMenuDemo.zip

    menuParams = (LinearLayout.LayoutParams) menu.getLayoutParams(); // 将menu的宽度设置为屏幕宽度减去menuPadding menuParams.width = screenWidth - menuPadding; // 左边缘的值赋值为menu宽度的负数 ...

    YCRedDotView-自定义红点控件,不用修改之前的代码,完全解耦,即可以设置红点数字控件,使用十分方便。可以支持设置在TextView,Button,LinearLayout,RelativeLayout,TabLayout等等控件上…….zip

     ViewGroup.LayoutParams parentLayoutParams = view.getLayoutParams();  badgeContainer.setLayoutParams(parentLayoutParams);  view.setLayoutParams(new ViewGroup.LayoutParams(  ViewGroup....

    ViewPagerFragment滑动切换

    .getLayoutParams(); int[] location = new int[2]; mTab1.getLocationInWindow(location); int marginLeft = (displayWidth / 4 - 122) / 2;//122是tab下面移动条的宽度 lp.setMargins(marginLeft, 0, ...

    android顶部滑动导航

    主界面 android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F0EFF5" > android:id="@+id/sayit_rl_tab" android:layout_width="fill_parent" ...

    android异步生成图片的示例代码

    下面来说说在Android上如果异步生成图片,通过xml布局用View排版好图片样式,在子线程生成一张图片,以满足生成用来分享的... int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getLayoutParams().width, Vie

    Android View 的尺寸大小变化的时候要求有一个过度的动画

    最近在项目里有个需求要求一个View 的尺寸大小变化的时候要求有一个过度的动画(view.getLayoutParams().height 100--->400)查看了一些资料后成功搞定,下面跟大家一起分享 解决的方法主要是继承Animation重写里面...

    TouchExtendView:Android 触摸扩展视图

    TouchExtendView 触碰范围扩大的View ##开发动机传统的按钮有效触碰范围可能就只有背景图片的可视范围内,但若是... LayoutParams LP = getLayoutParams(WH.getW(50),WH.getH(50)); LP.addRule(RelativeLayout.CENTER_

    自定义View中测量流程

    自定义View View的测量是从子View开始的,具体代码顺序是:父容器的onMeasure方法会遍历到每一个子childView –>然后调用... final LayoutParams lp = child.getLayoutParams(); final int childWidthMeasureSpec =

Global site tag (gtag.js) - Google Analytics