【问题标题】:ImageView aligned to the right side of parent in Xamarin AndroidImageView 在 Xamarin Android 中对齐到父级的右侧
【发布时间】:2016-10-27 02:17:19
【问题描述】:

当我运行这段代码时,imageView 向右对齐。我试过增加重力等,但没有成功。

我希望图标图像 (imageView) 显示在左侧,就在“声音”文本之前。

有什么想法吗?非常感谢。

protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
    {
        var cell = (SwitchCellView)base.GetCellCore(item, convertView, parent, context);
        cell.SetPadding(50, 0, 0, 0);

        var imageView = new ImageView(context);
        imageView.SetImageResource(Resource.Drawable.icon);

        cell.AddView(imageView, 50, 50);

        return cell;
    }

Result

【问题讨论】:

    标签: android xamarin xamarin.android xamarin.forms


    【解决方案1】:

    写作解决

    cell.AddView(imageView, 0);
    

    ... 这会将 imageView 添加到索引 0(左侧)。

    【讨论】:

      猜你喜欢
      • 2017-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多