Create RelativeLayout + childres via Xamarin.Android code

0

I have a problem with this, but I'm not sure what I'm trying to do. I'm not sure what I'd like to do. and I get the Rigth="ID" but it will not even a margin left is applied, I will post the code down to see if anyone thinks I'm wrong.

LayoutParamslp=newLayoutParams(LayoutParams.MatchParent,150);lp.Gravity=GravityFlags.Left;lp.LeftMargin=250;LayoutParamslp2=newLayoutParams(130,130);lp2.Gravity=GravityFlags.Left;LayoutParamslp3=newLayoutParams(LayoutParams.WrapContent,LayoutParams.WrapContent);lp3.Gravity=GravityFlags.Center;lp3.LeftMargin=12;//List<string>lista=dados2();//AbreConexao();line.RemoveAllViews();while(a!=dt.Rows.Count){//realtivolayoutvarrelative=newRelativeLayout(this){Id=int.Parse("10" + dt.Rows[a]["codigo"].ToString()),
                    };
                    relative.SetBackgroundResource(Resource.Drawable.backlinha);

                    //imagem do produto
                    Button myButton = new Button(this);
                    myButton.Gravity = GravityFlags.Left;
                    myButton.LayoutParameters = lp2;
                    //myButton.TranslationX = -52;
                    //myButton.TextAlignment = TextAlignment.Center;
                    //myButton.SetTextColor(Android.Graphics.Color.White);
                    //myButton.SetTextSize(Android.Util.ComplexUnitType.Dip,24);
                    //myButton.SetBackgroundResource(2130837599);
                    if (dt.Rows[a]["img"].ToString() != "")
                    {
                        byte[] data0 = (byte[])dt.Rows[a]["img"];
                        MemoryStream ms0 = new MemoryStream(data0);
                        myButton.SetBackgroundDrawable(Android.Graphics.Drawables.Drawable.CreateFromStream(ms0,"categoria"));
                    }
                    //myButton.Text = dt.Rows[a]["nome"].ToString();
                    myButton.Id = int.Parse(dt.Rows[a]["codigo"].ToString());
                    myButton.Click += myButon_cliki;
                    //myButton.id


                    //texto com o nome do produto
                    TextView txtprod = new TextView(this)
                    {
                        Right = int.Parse(dt.Rows[a]["codigo"].ToString()),Gravity = GravityFlags.Center

                    };

                    txtprod.TextSize = 24f;
                    txtprod.SetTextColor(Android.Graphics.Color.Black);
                    //txtprod.LayoutParameters = lp3;

                    txtprod.Text = dt.Rows[a]["nome"].ToString();
                    relative.SetGravity(GravityFlags.Center);
                    relative.AddView(txtprod);
                    relative.AddView(myButton);
                    relative.LayoutParameters = lp;

                    line.AddView(relative);

This line is a linearlayout

If someone can help me I'll be grateful

asked by anonymous 19.12.2018 / 05:31

0 answers