Reputation: 9894
How to set my FrameLayout's layout gravity programatically ?
Upvotes: 1
Views: 98
Reputation: 20348
You need to set it via LayoutParams
.
You can't set a Layout's gravity, you can set the gravity of Layout's members like this.
View view = new View(this);
FrameLayout.LayoutParams param = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
view.setLayoutParams(param);
Upvotes: 1