【问题标题】:Image with Entry and having a circular border带有条目并具有圆形边框的图像
【发布时间】:2015-10-03 11:05:06
【问题描述】:

有什么办法可以放置带有Entry并具有圆形边框的图像。 到目前为止,使用自定义 EntryRenderer 成功实现了圆形边框。但无法将图像放在该边框内。

 public class ExtendedEntryRender : EntryRenderer{

    protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
    {
        base.OnElementChanged(e);
        if (Control != null)
        {
            GradientDrawable gd = new GradientDrawable();
            gd.SetColor(Android.Graphics.Color.Argb(252, 247, 191, 178));
            gd.SetCornerRadius(30);
            gd.SetStroke(1, Android.Graphics.Color.Argb(252, 247, 191, 178));
            this.Control.SetBackgroundDrawable(gd);
            this.Control.SetTextColor(Android.Graphics.Color.Black);
            this.Control.SetCursorVisible(true);
        }
    }
}

谢谢

【问题讨论】:

  • 发布您尝试的问题
  • @Rahul 在 ExtendedEntryRender 类的 OnElementChanged() 中创建了 GradientDrawable
  • 有问题请发帖
  • @rahul 编辑了帖子
  • 如果你以图片的形式发布你得到的结果和你期望的结果,那将是很好的。

标签: android ios xamarin.forms


【解决方案1】:

如果我要尝试这样的事情。我可能会从 XLabs Circle Image Control 开始。 然后是类似于您所拥有的东西,然后将它们放在网格控件的同一个单元格中,以使它们彼此堆叠。

【讨论】:

    猜你喜欢
    • 2016-05-07
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-24
    相关资源
    最近更新 更多