Adam Varhegyi
Adam Varhegyi

Reputation: 9894

How to set the layout gravity for a layout, for example a FrameLayout?

How to set my FrameLayout's layout gravity programatically ?

Upvotes: 1

Views: 98

Answers (1)

0xC0DED00D
0xC0DED00D

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

Related Questions