[英]ConstraintLayout: how to divide screen in two equal parts of screen height programmatically
如何以編程方式將屏幕分成兩個相等的高度和約束布局?
為此,您需要將高度設置為零,然后相應地設置百分比。 例如,
ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) viewTop.getLayoutParams();
lp.height = 0;
lp.matchConstraintPercentHeight = (float) 0.5;
ConstraintLayout.LayoutParams lp2 = (ConstraintLayout.LayoutParams)viewBottom.getLayoutParams();
lp2.height = 0;
lp2.matchConstraintPercentHeight = (float) 0.5;
viewTop.setLayoutParams(lp);
viewBottom.setLayoutParams(lp2);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.