Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the percentage height/width of child views of PercentFrameLayout at runtime

Tags:

android

I want to set the child view's height/width of PercentFrameLayout programmatically. How to set the percentage height/width of child views of PercentFrameLayout at runtime..

like image 794
Rahul Rastogi Avatar asked Dec 18 '25 04:12

Rahul Rastogi


1 Answers

I assume that you have View with Id view_child inside of your PercentLayout.

so use this code snippet

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();

hope this help..

like image 102
Setmax Avatar answered Dec 20 '25 16:12

Setmax



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!