{"id":2891,"date":"2022-11-10T12:15:50","date_gmt":"2022-11-10T20:15:50","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/surface-duo\/?p=2891"},"modified":"2022-11-10T12:15:50","modified_gmt":"2022-11-10T20:15:50","slug":"net-maui-android-foldable","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/surface-duo\/net-maui-android-foldable\/","title":{"rendered":".NET MAUI for Android and cross-platform apps"},"content":{"rendered":"<p>\n  Hello .NET developers,\n<\/p>\n<p><a href=\"https:\/\/www.dotnetconf.net\/\">.NET Conf<\/a> is happening this week and one of the big announcements is the release of .NET 7 which includes an <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/dotnet-maui-dotnet-7\/\">updated release of .NET MAUI for .NET 7<\/a>. The latest .NET MAUI release includes dual-screen Android support based on Jetpack Window Manager, so you can build cross-platform apps for mobile and desktop that also adapt to foldable Android devices.\n<\/p>\n<h2>.NET MAUI (Multi-platform App UI)<\/h2>\n<p>\n  .NET MAUI lets you build apps for Android, iOS, macOS, Windows, and Tizen on all types of devices from mobile phones to tablets and desktop form factors. Apps are built with C# and XAML using Visual Studio on Windows or macOS. There is a huge variety of built-in controls and layouts, plus an ecosystem of component vendors including <a href=\"https:\/\/www.syncfusion.com\/maui-controls\">Syncfusion<\/a>, <a href=\"https:\/\/www.devexpress.com\/maui\/\">DevExpress<\/a>, <a href=\"https:\/\/grialkit.com\/\">UX Divers<\/a>, <a href=\"https:\/\/www.telerik.com\/maui-ui\">Telerik<\/a>, and more.\n<\/p>\n<p>\n  Check out all the cross-platform development features in the <a href=\"https:\/\/learn.microsoft.com\/dotnet\/maui\/\">.NET MAUI documentation<\/a> and <a href=\"https:\/\/dotnet.microsoft.com\/learn\/maui\">Learn .NET MAUI site<\/a>:\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"1829\" height=\"1016\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/a-picture-containing-graphical-user-interface-des.png\" class=\"wp-image-2892\" alt=\"Screenshot of the .NET MAUI training page on Microsoft Learn\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/a-picture-containing-graphical-user-interface-des.png 1829w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/a-picture-containing-graphical-user-interface-des-300x167.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/a-picture-containing-graphical-user-interface-des-1024x569.png 1024w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/a-picture-containing-graphical-user-interface-des-768x427.png 768w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/a-picture-containing-graphical-user-interface-des-1536x853.png 1536w\" sizes=\"(max-width: 1829px) 100vw, 1829px\" \/>\n<br\/><em>Figure 1: Learn .NET MAUI options on learn.microsoft.com<\/em>\n<\/p>\n<p>\n  If you\u2019ve previously worked with Xamarin.Forms, check out the <a href=\"https:\/\/learn.microsoft.com\/dotnet\/maui\/get-started\/migrate\">migration guidance<\/a> to update your apps to .NET MAUI!\n<\/p>\n<h2>Build Android apps<\/h2>\n<p>\n  The .NET MAUI documentation includes guidance specifically for building and deploying to Android:\n<\/p>\n<ul>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/maui\/get-started\/first-app?pivots=devices-android&amp;tabs=vswin\">Building your first Android app with .NET<\/a>\n  <\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/maui\/android\/emulator\/device-manager\">Managing Android emulators<\/a>\n  <\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/maui\/android\/device\/setup\">Testing on an Android device<\/a>\n  <\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/maui\/android\/deployment\/overview\">Deploying to Google Play or the Amazon app store<\/a>\n  <\/li>\n<\/ul>\n<p>\n  Here\u2019s an example of the <strong>File &gt; New<\/strong> app layout in XAML and how it looks in the emulator:\n<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;\r\n&lt;ContentPage xmlns=\"http:\/\/schemas.microsoft.com\/dotnet\/2021\/maui\"\u00a0xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2009\/xaml\"\u00a0x:Class=\"MauiApp999.MainPage\"&gt;\r\n\u00a0 \u00a0 &lt;ScrollView&gt;\r\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;VerticalStackLayout Spacing=\"25\" Padding=\"30,0\" VerticalOptions=\"Center\"&gt;\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;Image Source=\"dotnet_bot.png\" SemanticProperties.Description=\"Cute dot net bot waving hi to you!\" HeightRequest=\"200\" HorizontalOptions=\"Center\" \/&gt;\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;Label Text=\"Hello, World!\" SemanticProperties.HeadingLevel=\"Level1\" FontSize=\"32\" HorizontalOptions=\"Center\" \/&gt;\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;Label Text=\"Welcome to .NET Multi-platform App UI\" SemanticProperties.HeadingLevel=\"Level2\" SemanticProperties.Description=\"Welcome to dot net Multi platform App U I\" FontSize=\"18\" HorizontalOptions=\"Center\" \/&gt;\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;Button x:Name=\"CounterBtn\" Text=\"Click me\" SemanticProperties.Hint=\"Counts the number of times you click\" Clicked=\"OnCounterClicked\" HorizontalOptions=\"Center\" \/&gt;\r\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;\/VerticalStackLayout&gt;\r\n\u00a0 \u00a0 &lt;\/ScrollView&gt;\r\n&lt;\/ContentPage&gt;<\/pre>\n<p>\n  <img decoding=\"async\" width=\"250\" height=\"492\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/word-image-2891-2.png\" class=\"wp-image-2893\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/word-image-2891-2.png 250w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/word-image-2891-2-152x300.png 152w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/>\n<\/p>\n<p><em>Figure 2: .NET MAUI Android demo<\/em>\n<\/p>\n<p>\n  One of the great productivity features of .NET MAUI is <a href=\"https:\/\/learn.microsoft.com\/dotnet\/maui\/xaml\/hot-reload\">Hot Reload<\/a>, which enables you to view the result of XAML changes while debugging your app without having to rebuild and redeploy every time. Download <a href=\"https:\/\/learn.microsoft.com\/visualstudio\/install\/install-visual-studio?view=vs-2022\">Visual Studio 2022<\/a> to give it a try!\n<\/p>\n<h2>Updated TwoPaneView control<\/h2>\n<p>\n  One of the new features of .NET MAUI is the <strong>TwoPaneView<\/strong> control that ships in the <strong>Microsoft.Maui.Controls.Foldable<\/strong> NuGet. The TwoPaneView acts like a split view layout, with two child views and a variety of different display options:\n<\/p>\n<ul>\n<li>\n    Views side-by-side or on top of each other. Sizing can be controlled with a minimum height\/width set for the first child pane or specified proportionally.\n  <\/li>\n<li>\n    Show only the first or only the second pane.\n  <\/li>\n<li>\n    Swap the order of the child views.\n  <\/li>\n<li>\n    On dual-screen or foldable devices, snap the border betweent the views to the hinge or fold in the screen.\n  <\/li>\n<\/ul>\n<p>\n  The easiest way to get started with the TwoPaneView layout control is to try out the <a href=\"https:\/\/learn.microsoft.com\/samples\/dotnet\/maui-samples\/userinterface-controls-twopaneview\/\">playground sample<\/a> \u2013 it exposes most of the TwoPaneView properties as sliders and menus so you can interactively observe how they affect the layout on different screen sizes and device modes:\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"991\" height=\"782\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/graphical-user-interface-application-description.png\" class=\"wp-image-2894\" alt=\"Surface Duo running the .NET MAUI playground sample\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/graphical-user-interface-application-description.png 991w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/graphical-user-interface-application-description-300x237.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/graphical-user-interface-application-description-768x606.png 768w\" sizes=\"(max-width: 991px) 100vw, 991px\" \/>\n<\/p>\n<p><em>Figure 3: .NET MAUI TwoPaneView playground sample running on Surface Duo 2<\/em>\n<\/p>\n<p>\n  A basic TwoPaneView implementation is shown below \u2013 each pane contains a layout and the sizing and appearance can be controlled in XAML or in C# code.\n<\/p>\n<pre>&lt;ContentPage xmlns:foldable=\"clr-namespace:Microsoft.Maui.Controls.Foldable;assembly=Microsoft.Maui.Controls.Foldable\"&gt;\r\n  &lt;foldable:TwoPaneView&gt;\r\n      &lt;foldable:TwoPaneView.Pane1&gt;\r\n          &lt;StackLayout&gt;\r\n              &lt;Label Text=\"Pane1 Content\" \/&gt;\r\n          &lt;\/StackLayout&gt;\r\n      &lt;\/foldable:TwoPaneView.Pane1&gt;\r\n      &lt;foldable:TwoPaneView.Pane2&gt;\r\n          &lt;StackLayout&gt;\r\n              &lt;Label Text=\"Pane2 Content\" \/&gt;\r\n          &lt;\/StackLayout&gt;\r\n      &lt;\/foldable:TwoPaneView.Pane2&gt;\r\n  &lt;\/foldable:TwoPaneView&gt;\r\n&lt;\/ContentPage&gt;<\/pre>\n<p>\n  The TwoPaneView provides a flexible and adaptive layout that helps build apps that can scale from small phone form-factors to foldables and large-screen devices. Here is the layout on a tablet using the Pane1Length and Pane2Length to create a 1:3 split:\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"1386\" height=\"931\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/word-image-2891-4.png\" class=\"wp-image-2895\" alt=\"Tablet simulator showing the TwoPaneView control\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/word-image-2891-4.png 1386w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/word-image-2891-4-300x202.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/word-image-2891-4-1024x688.png 1024w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2022\/11\/word-image-2891-4-768x516.png 768w\" sizes=\"(max-width: 1386px) 100vw, 1386px\" \/>\n<br\/><em>Figure 4: .NET MAUI TwoPaneView playground creating a split view on a tablet<\/em>\n<\/p>\n<h2>\n  Resources and feedback\u00a0\n<\/h2>\n<p>\n  To learn more about .NET MAUI, start with this <a href=\"https:\/\/learn.microsoft.com\/dotnet\/maui\/get-started\/resources\">resources page<\/a>. \n<\/p>\n<p>\n  If you have any questions about building cross-platform apps that can run on Android and other devices, ask on our <a href=\"http:\/\/aka.ms\/SurfaceDuoSDK-Feedback\">feedback forum<\/a>\u00a0or message us on Twitter\u00a0<a href=\"https:\/\/twitter.com\/surfaceduodev\">@surfaceduodev<\/a>.\u00a0\u00a0\n<\/p>\n<p>\n  Finally, please join us for our\u00a0<a href=\"https:\/\/twitch.tv\/surfaceduodev\">dual screen developer livestream<\/a>\u00a0at 11am (Pacific time) each Friday \u2013 mark it in your calendar and check out the\u00a0<a href=\"https:\/\/www.youtube.com\/channel\/UClGu9QLtPNz8OdddBfhZXPA\">archives on YouTube<\/a>.\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello .NET developers, .NET Conf is happening this week and one of the big announcements is the release of .NET 7 which includes an updated release of .NET MAUI for .NET 7. The latest .NET MAUI release includes dual-screen Android support based on Jetpack Window Manager, so you can build cross-platform apps for mobile and [&hellip;]<\/p>\n","protected":false},"author":570,"featured_media":2894,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[722,727,717,182],"class_list":["post-2891","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-surface-duo-sdk","tag-net-maui","tag-c","tag-foldable","tag-xamarin-forms"],"acf":[],"blog_post_summary":"<p>Hello .NET developers, .NET Conf is happening this week and one of the big announcements is the release of .NET 7 which includes an updated release of .NET MAUI for .NET 7. The latest .NET MAUI release includes dual-screen Android support based on Jetpack Window Manager, so you can build cross-platform apps for mobile and [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/2891","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/users\/570"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/comments?post=2891"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/2891\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media\/2894"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media?parent=2891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/categories?post=2891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/tags?post=2891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}