我正在尝试在我的Xamarin应用程序中显示图像,但它似乎没有显示在屏幕上 . 该应用程序符合并运行时没有任何警告或错误,并且单独的图像成功显示为应用程序顶部的长工具栏 .

图像保存在我的Resources - > Drawable目录中 .

XAML

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:minWidth="25px"
    android:minHeight="25px"
    android:rowCount="5"
    android:columnCount="2">
    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        android:layout_height="150px"
        android:layout_width="match_parent" />
    <ImageView
        android:id="@+id/cardOne"
        android:layout_width="wrap_content"
        android:layout_height="150px"
        android:src="@drawable/m1"
        android:layout_row="3"
        android:layout_column="1" />
</GridLayout>

主要活动

var imageView = FindViewById<ImageView>(Resource.Id.cardOne);
    imageView.SetImageResource(Resource.Drawable.m1);