title: Saving bitmap from layout that contains views
body: <p>I cannot seem to save a layout and its view components as a bitmap.</p>
  
  <p>I am looking to implement something similar to these example, <a href="https://stackoverflow.com/questions/3095080/create-image-from-view-screen-in-android">Create image from view/screen in Android</a> ,
  <a href="https://stackoverflow.com/questions/21725916/convert-frame-layout-into-image-and-save-it">Convert frame layout into image and save it</a></p>
  
  <p>The problem I am having is in regards to methods like GetDrawingCache(), and DrawingCacheEnabled().
  It appears as if I cannot call them on a layout.</p>
  
  <p>Here are the ERRORS </p>
  
  <ol>
  <li><p>Error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement (CS0201) (APPNAME) </p></li>
  <li><p>Error CS1501: No overload for method 'GetDrawingCache' takes 0 arguments (CS1501) (APPNAME)</p></li>
  </ol>
  
  <p>I am currently coding in Monodroid/Xamarin. So the methods will seem a little different, but maybe someone can provide some insight. </p>
  
  <p><strong>ImageActivity</strong></p>
  
  <p>Here I am adding the views programmatically to a layout.</p>
  
  <pre><code>protected override void OnCreate (Bundle savedInstanceState)
  {
      base.OnCreate (savedInstanceState);
      image = new ImageView (this);
      //image = FindViewById&lt;ImageView&gt; (Resource.Id.imageView1);
      //this.image.SetScaleType (ImageView.ScaleType.CenterInside);
      //this.image.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
      SetContentView (Resource.Layout.Image);
      m_Layout = FindViewById&lt;FrameLayout&gt; (Resource.Id.editable_layout);
      m_Layout.AlwaysDrawnWithCacheEnabled;
  
      this.path = (savedInstanceState ?? Intent.Extras).GetString ("path");
      Title = System.IO.Path.GetFileName (this.path);
  
      Cleanup ();
      DecodeBitmapAsync (path, 400, 400).ContinueWith (t =&gt; {
          image = FindViewById&lt;ImageView&gt; (Resource.Id.imageView1);
          image.SetImageBitmap (this.bitmap = t.Result);
      }, TaskScheduler.FromCurrentSynchronizationContext ());
  
      btnAddImage1 = FindViewById&lt;ImageButton&gt; (Resource.Id.button1);
      btnAddImage2 = FindViewById&lt;ImageButton&gt; (Resource.Id.button2);
      btnAddImage2 = FindViewById&lt;ImageButton&gt; (Resource.Id.imageButton2);
  
      btnAddImage1.Click += (sender, e) =&gt; { 
          CustomImageView bitmapView = new CustomImageView (this, Resource.Drawable.big85);   
          m_Layout.AddView (bitmapView);
      };
  
      btnAddImage2.Click += (sender, e) =&gt; { 
          CustomImageView bitmapView = new CustomImageView (this, Resource.Drawable.curled5); 
          m_Layout.AddView (bitmapView);
  
      };
      btnConfirm.Click += (sender, e) =&gt; { 
          createBitmap();
      };
  
  }
  
  public void createBitmap(){
      m_Layout.DrawingCacheEnabled;
      m_Layout.BuildDrawingCache ();
      Bitmap m_Bitmap = Bitmap.CreateBitmap(m_Layout.GetDrawingCache());
  }
  </code></pre>
  
  <p><strong>XML for ImageActivity</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
      p1:orientation="vertical"
      p1:minWidth="25px"
      p1:minHeight="25px"
      p1:background="@color/gray_35"
      p1:layout_width="match_parent"
      p1:layout_height="match_parent"
      p1:id="@+id/root_layout"&gt;
      &lt;LinearLayout
          p1:orientation="horizontal"
          p1:minWidth="25px"
          p1:background="@drawable/red_noise_background"
          p1:minHeight="25px"
          p1:layout_width="match_parent"
          p1:layout_height="50dp"
          p1:id="@+id/linearLayoutActionBar"&gt;
          &lt;ImageButton
              p1:src="@drawable/ic_navigation_previous_item"
              p1:layout_width="wrap_content"
              p1:layout_height="fill_parent"
              p1:background="@color/transparent"
              p1:id="@+id/imageButton1" /&gt;
          &lt;LinearLayout
              p1:layout_width="2dp"
              p1:layout_height="fill_parent"
              p1:background="@color/pixagramdark_red" /&gt;
          &lt;TextView
              p1:text="Pixagram"
              p1:textColor="@color/white"
              p1:layout_weight="1"
              p1:textSize="24sp"
              p1:gravity="center"
              p1:layout_width="fill_parent"
              p1:layout_height="fill_parent"
              p1:id="@+id/textView1" /&gt;
          &lt;LinearLayout
              p1:layout_width="2dp"
              p1:layout_height="fill_parent"
              p1:background="@color/pixagramdark_red" /&gt;
          &lt;ImageButton
              p1:background="@color/transparent"
              p1:src="@drawable/ic_navigation_accept"
              p1:layout_width="wrap_content"
              p1:layout_height="fill_parent"
              p1:id="@+id/imageButton2" /&gt;
      &lt;/LinearLayout&gt;
      &lt;LinearLayout
          p1:layout_width="fill_parent"
          p1:layout_height="2dp"
          p1:background="@color/pixagramdark_red" /&gt;
      &lt;FrameLayout
          p1:layout_weight="1"
          p1:layout_width="match_parent"
          p1:layout_height="match_parent"
          p1:id="@+id/editable_layout"&gt;
          &lt;ImageView
              p1:src="@android:drawable/ic_menu_gallery"
              p1:layout_width="match_parent"
              p1:layout_height="match_parent"
              p1:id="@+id/imageView1" /&gt;
      &lt;/FrameLayout&gt;
      &lt;LinearLayout
          p1:layout_width="fill_parent"
          p1:layout_height="2dp"
          p1:background="@color/pixagramdark_red" /&gt;
      &lt;LinearLayout
          p1:orientation="vertical"
          p1:minWidth="25px"
          p1:background="@drawable/red_noise_background"
          p1:minHeight="25px"
          p1:layout_width="match_parent"
          p1:layout_height="75dp"
          p1:id="@+id/linearLayout1"&gt;
          &lt;HorizontalScrollView
              p1:layout_gravity="bottom"
              p1:gravity="bottom"
              p1:layout_width="fill_parent"
              p1:layout_height="fill_parent"
              p1:id="@+id/horizontalScrollView1"&gt;
              &lt;LinearLayout
                  p1:orientation="horizontal"
                  p1:layout_width="fill_parent"
                  p1:layout_height="fill_parent"
                  p1:id="@+id/linearLayout1"&gt;
                  &lt;ImageButton
                      p1:text="Button"
                      p1:layout_weight="1"
                      p1:layout_width="75dp"
                      p1:background="@color/transparent"
                      p1:layout_height="fill_parent"
                      p1:src="@drawable/big85"
                      p1:id="@+id/button1" /&gt;
                  &lt;ImageButton
                      p1:text="Button"
                      p1:background="@color/transparent"
                      p1:layout_weight="1"
                      p1:src="@drawable/curled5"
                      p1:layout_width="75dp"
                      p1:layout_height="fill_parent"
                      p1:id="@+id/button2" /&gt;
                  &lt;ImageButton
                      p1:text="Button"
                      p1:background="@color/transparent"
                      p1:layout_weight="1"
                      p1:layout_width="75dp"
                      p1:src="@drawable/curve21"
                      p1:layout_height="fill_parent"
                      p1:id="@+id/button3" /&gt;
                  &lt;ImageButton
                      p1:text="Button"
                      p1:layout_weight="1"
                      p1:src="@drawable/facial1"
                      p1:background="@color/transparent"
                      p1:layout_width="75dp"
                      p1:layout_height="fill_parent"
                      p1:id="@+id/button4" /&gt;
                  &lt;ImageButton
                      p1:text="Button"
                      p1:layout_weight="1"
                      p1:layout_width="75dp"
                      p1:src="@drawable/horseman1"
                      p1:background="@color/transparent"
                      p1:layout_height="fill_parent"
                      p1:id="@+id/button5" /&gt;
                  &lt;ImageButton
                      p1:text="Button"
                      p1:src="@drawable/thin20"
                      p1:layout_weight="1"
                      p1:background="@color/transparent"
                      p1:layout_width="75dp"
                      p1:layout_height="fill_parent"
                      p1:id="@+id/button6" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/HorizontalScrollView&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>