Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to set margin after to inflated view?

$
0
0

Please help I need to add -5dp margin but all off this tries not work for me. I don't know why. In axml is margin deffined too. No error or warning in output.

LayoutInflater inflater = (LayoutInflater)GetSystemService(Context.LayoutInflaterService);
layout.RemoveAllViewsInLayout();

for (int current = 0; current < list.Count; current++)
{
    RelativeLayout view = inflater.Inflate(Resource.Layout.ListRowLayout, null) as RelativeLayout;

    //var param = ((RelativeLayout.LayoutParams)new RelativeLayout.LayoutParameters).TopMargin = -5;// (ViewGroup.LayoutParams.FillParent, 60);
    //var param = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);
    var param = new RelativeLayout.LayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent) { TopMargin = -5 });
    //param.SetMargins(0, -5, 0, 0);
    //param.TopMargin = -5;
    view.LayoutParameters = param;
    //((ViewGroup)layout).AddView(view);
    layout.AddView(view, param);
}

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>