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

Fill background colour to occupy entire grid cell

$
0
0

I have a grid cell with span labels. Each span label is of different length size with different background colour.

How do I add background colour so that entire grid cell is occupied.

formattedString.Spans does not have definition for HorizontalOptions (where I couldset the layout to FillAndExpand).

var formattedString = new FormattedString();
formattedString.Spans.Add(new Span
            {
                Text = name,
                /// HorizontalOptions = LayoutOptions.FillAndExpand,
                TextColor = Color.Black,
                BackgroundColor = Color.LightSkyBlue,
              });

            formattedString.Spans.Add(new Span
            {
                Text = age,
                FontAttributes = FontAttributes.Italic,
                TextColor = Color.Black,
                BackgroundColor = Color.SkyBlue,
            });

  Grid grid = new Grid();
  Label details = new Label
            {
                FormattedText = formattedString,
                VerticalOptions = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand
             };
  grid.Children.Add(details,0,0);

Viewing all articles
Browse latest Browse all 204402

Trending Articles



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