代码修改高度代码修改宽度

RelativeLayout (随控件父视图)

RelativeLayout.LayoutParams tvNumberParams = (RelativeLayout.LayoutParams)tvNumber.getLayoutParams();
        tvNumberParams.height=(int) context.getResources().getDimension(R.dimen.DIMEN_80dp);
        tvNumber.setLayoutParams(tvNumberParams);



//等带初始化后才能获取真实高度
        tvNumber.post(new Runnable() {
            @Override
            public void run() {
                RelativeLayout.LayoutParams tvNumberParams = (RelativeLayout.LayoutParams)tvNumber.getLayoutParams();
                tvNumberParams.height= tvNumber.getWidth();
                tvNumber.setLayoutParams(tvNumberParams);
            }
        });

你可能感兴趣的:(代码修改高度代码修改宽度)