Skip to content

nativecode-dev/oss-xamarin

Repository files navigation

Obsolete

Due to Xamarin.Forms 2.0 now providing Material Design compatibility through the FormsAppCompatActivity, this project really is no longer needed. There may be some things from this project that can be ported, but I'll be exploring that option if it presents itself in my day to day Xamarin use. Thanks to everyone who has reported issues and tried it out!

PSA

You probably shouldn't upgrade to Xamarin.Android 5.1.4 until they fix the debug issues. Currently, the only way to debug Android apps is to disable all linking.

Please see all the comments here. If you already upgraded to 5.1.4 and are experiencing issues, it's recommended to downgrade to 5.1.3 until the issues are resolved.

Provide Material Design themes now for Xamarin.Forms apps natively without hacks! Check out the wiki for more information. And yes, I blogged about it.

NOTE: As it is still very early in the project (v1.1 will be considered production ready), expect breaking changes.

Release Development

Simply install the NuGet package into your Android project.

Install-Package NativeCode.Mobile.AppCompat

Once installed, you should replace your FormsApplicationActivity derived activities with AppCompatFormsApplicationActivity.

For instance:

public class MainActivity : AppCompatFormsApplicationActivity
{
  protected override void OnCreate(Bundle savedInstanceState)
  {
    base.OnCreate(savedInstanceState);

    Forms.Init(this, savedInstanceState);

    this.LoadApplication(new App());
  }
}

You can then use the normal Forms.Init and LoadApplication methods to initialize your activities. You also no longer need to define your own styles.xml as you can use the ones already packaged (the exception is if you want your own colors).

The following styles are available:

  • CompatTheme (Theme.AppCompat)
  • CompatThemeLight (Theme.AppCompat.Light)
  • CompatThemeLightDarkActionBar (Theme.AppCompat.Light.DarkActionBar)

Simply install the NuGet package into your PCL project that contains your UI. NOTE: You must install the Renderers package into your Android project.

Install-Package NativeCode.Mobile.AppCompat.Controls

Available controls

Simply install the NuGet package into your Android project.

Install-Package NativeCode.Mobile.AppCompat.Renderers

Once installed, you will have to call AppCompatRenderers.EnableAll inside your OnCreate, after Forms.Init is called. This will register all of the AppCompat renderers to replace existing Xamarin.Forms renderers.

public class MainActivity : AppCompatFormsApplicationActivity
{
  protected override void OnCreate(Bundle savedInstanceState)
  {
    base.OnCreate(savedInstanceState);

    Forms.Init(this, savedInstanceState);
    FormsAppCompat.EnableAll();

    this.LoadApplication(new App());
  }
}

Current Renderers

Devices Tested

Phones

  • Nexus 5 (emulator)
  • Samsung Galaxy S6

phone

Tablets

  • Samsung Tab 7
  • Nexus 7

tablet

LICENSE

   Copyright 2015 NativeCode Development

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.