RelativeLayout mRelativeLayout; //待修改的布局或控件
/**获取原先控件的大小属性**/
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)mRelativeLayout.getLayoutParams();
/**修改原先控件的大小 以dp的形式**/
lp.height= ((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,196, getResources().getDisplayMetrics()));
/**调整内距**/
mRelativeLayout.setPadding(((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,10, getResources().getDisplayMetrics())),0,((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,10, getResources().getDisplayMetrics())),0);
/**保存调整属性**/
mRelativeLayout.setLayoutParams(lp);
网友评论