Hello everyone!
I am currently working with Xamarin.Forms and I am trying to create a custom PageRenderer for Android which would display a stream from the camera. In every example I have met, the custom view was created thanks to a layout axml file located in Resources\layout that was called thanks to the command view = activity.LayoutInflater.Inflate (Resource.Layout.CameraLayout, this, false);
such as in this example, which I am trying to replicate.
The problem is that Visual Studio does not display the subfolder layout inside Resources (the only subfolder shown is drawable). I tried navigating there and creating manually CameraLayout.axml but my program still refused to build when I called view = activity.LayoutInflater.Inflate (Resource.Layout.CameraLayout, this, false);
explaining that "Resources.Layout contains no definition for CameraLayout". The strange thing is that when I work on another application developed with Xamarin (not Xamarin.Forms), that folder is shown and I face no problem when building the application.
Has anyone faced that problem before? If yes, how did you create your custom Android view?
I am quite new to Xamarin and Xamarin.Forms so there might be something obvious I have missed. I am working with Visual Studio 2015 on Windows 7.
Thank you kindly to anyone who will take the time to answer.
Maxime Larcher
Thank you for your answer @Hunuman, it did not directly solve the problem but helped me figure how to solve it.
If anyone encountered the same issue, that's how I solved it:
The folder Resource.Layout was hidden by default. To show it, go in the solution explorer and click on "Show all files". Then right click on Layout folder and choose "Include in Project".
After that you can add files by Right Clicking --> Add New/Add existing.
Answers
@MaximeLarcher
With Xamarin.Forms I've always had to manually add the resource/sub-folders/items, into the android project, by right clicking the project->Add->Existing Item.
Apologies if not applicable.
Tim
Thank you for your answer @Hunuman, it did not directly solve the problem but helped me figure how to solve it.
If anyone encountered the same issue, that's how I solved it:
The folder Resource.Layout was hidden by default. To show it, go in the solution explorer and click on "Show all files". Then right click on Layout folder and choose "Include in Project".
After that you can add files by Right Clicking --> Add New/Add existing.
Hello I know this is an old thread but I am having the same issue. Going into the project files using File Explorer I can see that there is no subfolder layout in the Resources folder at all with Xamarin.Forms. However
Resources.Layout
still comes up with options. Can I just manually add a layout folder or should I try and locate where this so calledResources.Layout
is located?