Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Environment.NewLine

$
0
0

I have a custom renderer for a listview, code pasted below. My problem is that when I include an "Environment.NewLine" in the text of the secondary text, it is not placing text on a new line. It just continues on the same line, and does not show the newline character.

    public class HomeListTextCellRenderer : TextCellRenderer
        {
            protected override View GetCellCore (Cell item, View convertView, ViewGroup parent, Context context)
            {
                try
                {
                    var cell = (LinearLayout)base.GetCellCore(item, convertView, parent, context);
                    cell.SetPadding(0, 5, 5, 5);
                    cell.DividerPadding = 50;

                    var div = new ShapeDrawable();
                    div.SetIntrinsicHeight(1);
                    div.Paint.Set(new Paint { Color = Color.Gray.ToAndroid() });

                    if (parent is ListView)
                    {
                        ((ListView)parent).Divider = div;
                        ((ListView)parent).DividerHeight = 1;
                    }

                    var label = (TextView)((LinearLayout)cell.GetChildAt(1)).GetChildAt(0);
                    label.SetTextColor(Color.FromHex("000000").ToAndroid());
                    label.TextSize = Font.SystemFontOfSize(NamedSize.Medium).ToScaledPixel();

                    var secondaryLabel = (TextView)((LinearLayout)cell.GetChildAt(1)).GetChildAt(1);
                    secondaryLabel.SetTextColor(Color.FromHex("738182").ToAndroid());
                    secondaryLabel.TextSize = Font.SystemFontOfSize(NamedSize.Small).ToScaledPixel();

                    return cell;
                }
                catch (Exception ex)
                {

                }
                return new LinearLayout(context);
            }
        }

Viewing all articles
Browse latest Browse all 58056

Trending Articles



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