我想以编程方式设置 subview 的 PercentFrameLayout 高度/宽度。如何在运行时设置 PercentFrameLayout 的 subview 的百分比高度/宽度..
最佳答案
我假设您的 PercentLayout 中有 ID 为 view_child 的 View 。
所以使用这个代码 fragment
View view = findViewById(R.id.view_child);
PercentRelativeLayout.LayoutParams params =(PercentRelativeLayout.LayoutParams) view.getLayoutParams();
// This will currently return null, if view not exist in your xml.
PercentLayoutHelper.PercentLayoutInfo info = params.getPercentLayoutInfo();
info.heightPercent = 0.60;
view.requestLayout();
希望这对你有帮助..
关于android - 如何在运行时设置 PercentFrameLayout 的 subview 的百分比高度/宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32497833/