Monogame layer background is not transparent in Xamarin Android

Is there any sample code to place 3d model on top of camera in Xamarin Android?

I have try this by using FrameLayout following this guidance

http://www.infinitespace-studios.co.uk/general/getting-started-on-argumented-reality-using-xamarin-android-and-monogame/

but the 3d model background of monogame is not transparent?

Any idea?

have you tryed color.transparent. Even you are clearing the screen in monogamies’.

Hard to help without any code to look at.

Here is my code. For testing I just use an image at background instead of camera feed. Any idea?

This is Android activity:

 [Activity(Label = "Game1"
        , MainLauncher = true
        , Icon = "@drawable/icon"
        , AlwaysRetainTaskState = true
        , LaunchMode = Android.Content.PM.LaunchMode.SingleInstance
        , ScreenOrientation = ScreenOrientation.SensorLandscape
        , ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize)]
    public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.SetContentView(TestFBX.Resource.Layout.layout1);
            var gameWindowLayout = FindViewById<RelativeLayout>(TestFBX.Resource.Id.gameWindow);
            var game1 = new Game1();
            gameWindowLayout.AddView(game1.Services.GetService<View>());
            game1.Run(GameRunBehavior.Asynchronous);
        }
    }

Here is layout1.axml:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">     
     
<!--This is my background image in Android-->
      <ImageView
          android:id="@+id/flag"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"            
          android:src="@drawable/stars" />

<!-- This is where Monogame layer will appear over above background image -->
      <RelativeLayout
            android:id="@+id/gameWindow"
            android:layout_width="800dp"
            android:layout_height="800dp"
            android:layout_alignParentTop="true"
            android:layout_marginTop="20dp"        
            android:background="#00ffffff"> 
      </RelativeLayout>

    </RelativeLayout>

Here is Game1.cs, just use default code with clear background transparent:

public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.IsFullScreen = true;
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 480;
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
        }

        Matrix projection;

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// game-specific content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
           
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                Exit();

            // TODO: Add your update logic here            

            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Transparent);
         
            base.Draw(gameTime);
        }
    }

And if I use following code to change the Game surface format to Rgba8888:

var game1View = game1.Services.GetService<View>();
game1View.JavaCast<OpenTK.Platform.Android.AndroidGameView>().SurfaceFormat = Android.Graphics.Format.Rgba8888;

It will throw exception:

System.InvalidCastException: Unable to convert instance of type 'Microsoft.Xna.Framework.MonoGameAndroidGameView' to type 'OpenTK.Platform.Android.AndroidGameView'.

I am using Monogame 3.5

Ok it works now.

It turns out that I have to reference to OpenTK-1.0 dll instead of OpenTK.

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v7.0\OpenTK-1.0.dll