{"id":18098,"date":"2015-04-16T12:54:22","date_gmt":"2015-04-16T19:54:22","guid":{"rendered":"http:\/\/blog.xamarin.com\/?p=18098"},"modified":"2015-04-16T12:54:22","modified_gmt":"2015-04-16T19:54:22","slug":"more-material-design-for-your-android-apps","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/more-material-design-for-your-android-apps\/","title":{"rendered":"More Material Design for Your Android Apps"},"content":{"rendered":"<p>\t\t\t\t<img decoding=\"async\" class=\"alignright wp-image-18108 size-full\" src=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/fab-icon.png\" alt=\"fab icon\" width=\"114\" height=\"114\" \/>Android developers have been flocking to Material Design since its introduction with the release of Android Lollipop. With the recent update to the <a href=\"\/android-tips-hello-material-design-v7-appcompat\/\" title=\"Introduction to Material Design v7 AppCompat\">Support v7 AppCompat library<\/a> it has never been easier to add Material Design to target older Android operating systems.<\/p>\n<p>Material Design is much more than just the core theming and styling that you are able to add to your application \u2014 it&#8217;s animations, layouts, and of course controls. While many controls are available out of the box, there are many custom controls that can spice up your application with even more Material Design. Many of these controls are now available in the Xamarin Component store so you can instantly add them to your Xamarin.Android application. Let&#8217;s take a look at a few.<\/p>\n<h2>Floating Action Button<\/h2>\n<p><img decoding=\"async\" class=\"alignright size-medium wp-image-18099\" src=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/patterns_actions_fab1-169x300.png\" alt=\"Floating Action Button\" width=\"169\" height=\"300\" \/>When developing applications, you often have a main action that your users can perform on a page such as add, edit, delete. The <a href=\"http:\/\/www.google.com\/design\/spec\/components\/buttons-floating-action-button.html#\" title=\"Floating Action Button Design Guidelines\">floating action button<\/a> (FAB) was introduced to enable you to promote your main action with a beautiful and distinguished circled icon floating on the user interface. The floating action button is great because it helps bring context and awareness to the action that you want your users to perform, and you can add it to your Android app with the new <a href=\"https:\/\/components.xamarin.com\/view\/fab\" title=\"Floating Action Button\">Floating Action Button component<\/a>.<\/p>\n<p>Once you have the component installed, you can add a FAB to any layout by referencing the custom control.<\/p>\n<pre class=\"lang:xml decode:true\">\n&lt;com.refractored.fab.FloatingActionButton\n            android:id=&quot;@+id\/fab&quot;\n            android:layout_width=&quot;wrap_content&quot;\n            android:layout_height=&quot;wrap_content&quot;\n            android:layout_gravity=&quot;bottom|right&quot;\n            android:layout_margin=&quot;16dp&quot;\n            android:src=&quot;@drawable\/ic_action_content_new&quot; \/&gt;\n<\/pre>\n<p>Now you can find the FAB and add a click handler just like any other button.<\/p>\n<pre class=\"lang:csharp decode:true\">\nvar fab = root.FindViewById&lt;FloatingActionButton&gt;(Resource.Id.fab);\nfab.Click += (sender, args) =&gt;\n{\n  Toast.MakeText(Activity, &quot;FAB Clicked!&quot;, ToastLength.Short).Show();\n};\n<\/pre>\n<p>Be sure to read through the <a href=\"https:\/\/components.xamarin.com\/gettingstarted\/fab\" title=\"Floating Action Button Getting Started Guide\">getting started guide<\/a> to see how you can show and hide the FAB with a few simple calls or even attach it to a ListView to have it automatically hide when the list is scrolled.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-medium wp-image-18101\" src=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/fab_demo.gif\" alt=\"fab_demo\" width=\"189\" height=\"300\" \/><\/p>\n<h2>Pager Sliding Tab Strip<\/h2>\n<p>If you are an Android user, you may have noticed the beautiful Tabs that are part of the Google Play Store when browsing. The Material theme provides an updated look and feel to tabs, but it doesn&#8217;t introduce an updated View Pager Indicator. This is where the <a href=\"https:\/\/components.xamarin.com\/view\/PagerSlidingTabStrip\" title=\"Pager Sliding Tab Strip Component\">Material Pager Sliding Tab Strip<\/a> component comes in to enable you to easily add highly customizable and beautiful tabs to your Android app.<\/p>\n<p>After downloading the component, simply add the PagerSlidingTabStrip on top of your ViewPager in your layout.<\/p>\n<pre class=\"lang:xml decode:true\">\n&lt;com.refractored.PagerSlidingTabStrip\n        android:id=&quot;@+id\/tabs&quot;\n        android:layout_width=&quot;match_parent&quot;\n        android:layout_height=&quot;?attr\/actionBarSize&quot;\n        android:background=&quot;?attr\/colorPrimary&quot;\n        app:pstsPaddingMiddle=&quot;true&quot;\/&gt;\n&lt;!--Set pstsPaddingMiddle to false to start tabs on left--&gt;\n&lt;android.support.v4.view.ViewPager\n        android:id=&quot;@+id\/pager&quot;\n        android:layout_width=&quot;match_parent&quot;\n        android:layout_height=&quot;0dp&quot;\n        android:layout_weight=&quot;1&quot;\n        tools:context=&quot;.MainActivity&quot; \/&gt;\n<\/pre>\n<p>Then find your ViewPager and PagerSlidingTabStrip and connect them together with any FragmentPagerAdapter.<\/p>\n<pre class=\"lang:csharp decode:true\">\n\/\/ Initialize the ViewPager and set an adapter\nvar pager =  FindViewById&lt;ViewPager&gt;(Resource.Id.pager);\npager.Adapter = new TestAdapter(SupportFragmentManager);\n\n\/\/ Bind the tabs to the ViewPager\nvar tabs = FindViewById&lt;PagerSlidingTabStrip&gt;(Resource.Id.tabs);\ntabs.SetViewPager(pager);\n<\/pre>\n<p><img decoding=\"async\" class=\"aligncenter size-medium wp-image-18103\" src=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/material_tabs-1.gif\" alt=\"material_tabs demo\" width=\"175\" height=\"300\" \/><\/p>\n<p>For a full sample and to see how to customize the pager sliding tab strip even further, be sure to dive through the documentation and <a href=\"https:\/\/components.xamarin.com\/gettingstarted\/pagerslidingtabstrip\" title=\"Pager Sliding Tab Strip Getting Started\">getting started guide<\/a> for the component.<\/p>\n<h2>More Material!<\/h2>\n<p>Material Design integration into your Android apps doesn&#8217;t stop here. Be sure to read through our <a href=\"\/introduction-to-android-material-design\/\" title=\"Introduction to Material Design\">Introduction to Material Design<\/a>, Support v7 AppCompat Library, and the new Android Toolbar. Another great resource are the two presentations that J\u00e9r\u00e9mie Laval and I gave at Xamarin Evolve 2014, Android Material Design from Concept to Implementation <a href=\"https:\/\/www.youtube.com\/watch?v=A1WKe08uxd4\" title=\"Material Design Evolve Part 1\">Part 1<\/a> and <a href=\"https:\/\/www.youtube.com\/watch?v=_q9lorDZn0Y\" title=\"Material Design Evolve Part 2\">Part 2<\/a>.\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Android developers have been flocking to Material Design since its introduction with the release of Android Lollipop. With the recent update to the Support v7 AppCompat library it has never been easier to add Material Design to target older Android operating systems. Material Design is much more than just the core theming and styling that [&hellip;]<\/p>\n","protected":false},"author":544,"featured_media":39167,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[5,4],"class_list":["post-18098","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-android","tag-xamarin-platform"],"acf":[],"blog_post_summary":"<p>Android developers have been flocking to Material Design since its introduction with the release of Android Lollipop. With the recent update to the Support v7 AppCompat library it has never been easier to add Material Design to target older Android operating systems. Material Design is much more than just the core theming and styling that [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/18098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/544"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=18098"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/18098\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/39167"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=18098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=18098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=18098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}