PercentRelativeLayout, how to set the height programatically

来源:互联网 发布:指纹解锁软件 编辑:程序博客网 时间:2024/05/21 21:54
Do you want to set a new percentage value? If yes, you need to:View view = findViewById(R.id.view_child);PercentRelativeLayout.LayoutParams params = (PercentRelativeLayout.LayoutParams) view.getLayoutParams();// This will currently return null, if it was not constructed from XML.PercentLayoutHelper.PercentLayoutInfo info = params.getPercentLayoutInfo();info.heightPercent = 0.60f;view.requestLayout();


动态改变百分比布局的比例,注意这句话,

// This will currently return null, if it was not constructed from XML.PercentLayoutHelper.PercentLayoutInfo info = params.getPercentLayoutInfo();

0 0
原创粉丝点击