我的布局xml中有一个线性布局:
<LinearLayout
android:id="@+id/loginForm_LinearLayout" `
android:orientation="vertical"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
...some item...
</LinearLayout> `
但是当程序运行时,我必须更改此Linear Layout
的保证金顶部。怎么能在xamarin
中做到?
答案 0 :(得分:0)
试试这个
LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
ll.SetMargins (0,0,0,10);
mainPanel.LayoutParameters = ll
OR
var mainPanel = FindViewById<LinearLayout>(Resource.Id.mainasdf);
var linearLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent,
ViewGroup.LayoutParams.FillParent);
linearLayoutParams.SetMargins(0, 0, 0, 0);
mainPanel.LayoutParameters = linearLayoutParams