Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewStub's layout root element margins

Tags:

android

LinearLayout doesn't have margins after iflating ViewStub. After inflating I can set margins only programmaticaly or there is another way?

like image 344
Yrgl Avatar asked Oct 11 '13 11:10

Yrgl


1 Answers

I ran into the same issue but with a RelativeLayout. I fixed it by putting the margins on the ViewStub definition. This may not be the best way to do it, the best way might be having a hierarchical layout where the first child of your root layout is the one that has the margins set and contains all other elements.

Not sure of the root cause for this, but these are the two workarounds I know of.

like image 72
rob.todd Avatar answered Sep 17 '22 23:09

rob.todd