Reputation: 544
I can able to set padding for linear layout. But I need to set padding for the children inside a linear layout. Please find my codes below,
LinearLayout linear1 = new LinearLayout(BaseContext);
TextView textView = new TextView(BaseContext);
linear1.AddView(textView,100,100); (or) linear1.AddView(textView,LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
SetContentView(linear1);
Now I need to set padding for the TextView loaded inside a linear layout. Is it possible?
Thanks in advance.
Upvotes: 1
Views: 547
Reputation: 544
We can set padding for the children inside a linear layout like below,
LinearLayout linear1 = new LinearLayout(BaseContext);
TextView textView = new TextView(BaseContext);
linear1.AddView(textView,100,100);
LinearLayout.LayoutParams options = (LinearLayout.LayoutParams)textView.LayoutParameters; //where textView is the view loaded inside a linear layout.
options.LeftMargin = 30;
options.TopMargin = 30;
options.RightMargin = 30;
options.BottomMargin = 30;
SetContentView(linear1);
Upvotes: 1