0

I'm trying to display an image in my Xamarin app but it does not seem to be displaying on the screen. The app complies and runs without any warnings or errors, and a separate image is displaying successfully as a long toolbar along the top of the app.

The images are held within my Resources -> Drawable directory.

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>

MainActivity

    var imageView = FindViewById<ImageView>(Resource.Id.cardOne);
    imageView.SetImageResource(Resource.Drawable.m1);
Colin747
  • 4,955
  • 18
  • 70
  • 118
  • you can use this way:[Link] (https://stackoverflow.com/questions/3787137/change-image-source-in-code-behind-wpf?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa) – Carlos Henrique Apr 10 '18 at 11:08
  • That seems to be a different problem regarding dynamic image allocation from a network stored image? – Colin747 Apr 10 '18 at 11:11
  • have you tried to set the image Resource on CodeBehind from xaml? or is already on codebehind? – Carlos Henrique Apr 10 '18 at 11:28

0 Answers0