Saturday, August 15, 2015

5 Tips to Properly Style Xamarin.Forms Apps



Xamarin.Forms’ default templates for applications are great! They give you everything you need to get up and running including all three of your app projects and your shared code project. Nothing is faster than this to get a cross-platform application spun up. One thing they don’t do by default is setup nice themes for your applications, in fact they simply use the default device themes, but we can do better. I wanted to take a quick second to share a few tips on making your Xamarin.Forms app beautiful with just a few lines of code.

Tip 0: Pick a color palette

I had to start my tips at 0 because this tip is so important for your application. Your application needs an identity and a base to start with… a palette that you can pick from.
Take a hint from Google and browse through their Color guidelines and then use http://www.materialpalette.com/ to pick your colors. Use these not only in the app specific theme for Android, but throughout your Xamarin.Forms applications using Styles.

Tip 1: Use a Light Theme

Light themes are iOS’s default theme. Don’t fight it, embrace it. By embracing the light theme there is no need to ever set any custom colors in your application. There is a bit of setup required to get this going on each platform using your new palette.
Android
I have covered this in the past so I wont repost the code, but GO READ THIS POST!! Understanding Android app themes is very important. By applying default Light Holo and Material themes to your application you can completely transform your application.
iOS
There is very little that you need to do to optimize iOS applications since the core theme is already light. The only thing to update is the Status Bar color, which I blogged about earlier, and the title bar color itself. You can accomplish this by opening our AppDelegate.cs and applying a few lines of code in the FinishedLaunching:
view raw AppDelegate.cs hosted with ❤ by GitHub
Windows Phone
Let’s not forget about Windows Phone as it is the most interesting. By default Windows Phone (silverlight) apps change their themes based on the user preference. You will normally see a dark theme as this is the phone default, but there is a nifty NuGet package from my hero Jeff Wilcox that enables you to manually force a theme for your application. Follow his nifty guide to get you up and running.
Side Tip: On a NavigationPage you may want to set the BarTextColor to White or a shade of black

Tip 2: Don’t set background colors

Unless you decided to ignore Tip 1 and need to go with a custom dark theme there is no need to ever set a background color in Xamarin.Forms for an entire page. You could set it for portion of the page or perhaps strips, but never the full page. Let the main applications theme work for you. This will ensure your font colors work correctly out of the box.

Tip 3: Don’t Use Custom Fonts

Don’t do it unless you REALLY REALLY have to. There is no need to put a comic sans font in your application. Let the platforms work for you. iOS does have plenty of great fonts built right in and I do recommend you customize your iOS apps using these, however let Android’s Roboto and Windows Phone’s Segeo WP work for you.

Tip 4: Padding & Spacing

This tip requires a bit more of an eye for design and a bit of energy. Each platform has some specific requirements around the default padding and spacing that is between controls on the page. Android uses a 8dp baseline grid for components 4dp baseline grid for type alignment.
Windows Phone on the other hand uses a 10 pixel spacing grid between everything on the screen. Take a look at Jeff Wilcox’s Windows Phone MetroGridHelper to enable an overlay to help with spacing.
You can use Xamarin.Forms Device.OS and OnPlatform to do custom tweaks to your Padding.

Source: http://goo.gl/xyf2nh


Xamarin.Forms in Anger – Cards


Screen Shot 2015-07-15 at 12.08.48 PM

The #1 request I get for the Xamarin.Forms in Anger is for a Google or Facebook like card view. Today is the day that I fulfill those requests.
To be completely honest, I’ve been thinking about how to do a card view for a while and let me tell you, it’s not easy. Especially when you try to stick with the “in the box” components of Xamarin.Forms. My first attempt at it was hideous.

Hideous Forms

Hideous would be the most polite way of saying it was crap. I started off using BoxViews to draw the lines and contain the whole thing in a Xamarin.Forms Grid. Ouch, yes hideous.
The Grid was becoming a nightmare with all the extra rows and columns needed for lines. What I wouldn’t do for some HTML Tables with a borders = 1 in Xamarin.Forms. I thought of putting in a feature request to the team, but didn’t. I don’t want them to laugh at me. 😉

A Grid of Lines

I worked up a Xamarin.Forms Grid with some padding, row and column spacing. In addition to those settings, I also set the background color of the grid to a medium dark grey. Then added ContentViews with white backgrounds into each cell of the Grid. This is what it looked like when I finished.
GridLines
The white panels acted like the ketchup on my waffle fries and the borders are the potato. Yes, I know, it’s strange to describe Xamarin.Forms design techniques using food, but stay with me; it gets better. Now that I knew the technique worked and was a heck of a lot less messy, I pushed on.

Content View Panels

Each CardView is made up of 5 ContentViews with a background color set to the designed color. Here are some of the background colors for each panel.
Panels
The CardView.cs file would have been gigantic if I kept all the code in the same file so I broke it up into different ContentViews. Here are the names for each ContentView that makes up the CardView.
CardViews
The CardDetailsView has a column span of three to horizontally bridge the two IconLableViews and the ConfigIconView. The CardStatusView has a row span of two to complete the vertical lefthand status bar.

The CardView Code

For the demo, I put a couple of CardViews in a vertical StackLayout. If I had a lot of cards, I would prefer to use a ListView. Hopefully a reader will let me know how well this design works in a ListView. It should be ok, especially while using the Grid and not a bunch of nested StackLayouts. I’ve learned my lesson.
With all the refactoring; the CardView looks small and plain but the devil is in the ContentViews.

Solution

The code for this sample is up on GitHub in the “In Anger” repository. For this post, I broke the code out into a separate directory and solution to make it easier for you to reuse the CardView without getting confused with all the other code and resources from other posts.

Source: goo.gl/aCHqyu

Thursday, August 13, 2015

Google Will Soon Bring Metal-Like, Low-Overhead Graphics API To Android


Google today announced that it will soon support the Khronos Group’s Vulkan graphics API on Android.
The goal of Vulkan is very similar to that of Apple’s Metal API for iOS and OS X. Vulkan is a low-overhead graphics API that gives developers more direct access to the graphics processor and control over how their graphics are rendered.
In today’s announcement, Google argues that current APIs are “not designed for multi-threaded use, requiring synchronization with locks around calls that could be more efficiently done in parallel.”
The Vulkan API is being developed and maintained by the Khronos Group — the organization behind OpenGL,WebGL and similar standards. Indeed, Vulkan is essentially the next generation of OpenGL. The Khronos group first announced Vulkan in March, together with a range of software and hardware partners. But the API needs support from the operating system, too, and at the time, Google wasn’t yet on board.
opengl-vs-vulkan
“Hardware and software companies need an open 3D API to maximize market reach and minimize porting costs, and Vulkan is being forged by a broad consortium of industry leaders to do exactly that,” said Neil Trevett, president of the Khronos Group. “Vulkan’s adoption and availability on platforms such as Android, Windows, Linux and SteamOS will ensure strong developer support – creating a wealth of high-quality content and applications for any platform that leverages this royalty-free standard.”
The standard is still a work in progress, though. Chances are it won’t be part of Google’s Android M operating system when it launches later this year, but companies like Imagination Technologies (the company behind the PowerVR GPUs) are already demoing Vulkan’s power on Android today (using a prototype driver).
Google supports the OpenGL ES standard on Android, and the company says it will continue to do so. OpenGL ES will likely remain easier to use for developers for the time being, but Vulkan will give them more control.
“We’re committed to providing an excellent developer experience, no matter which API you choose,” Google technical program manager Shannon Woods says in today’s announcement.
https___www_khronos_org_assets_uploads_developers_library_overview_2015_vulkan_v1_Overview_pdf

Wednesday, August 12, 2015

It's now possible to run Android apps on Windows 10 Mobile







For many months, we had been reporting that Microsoft was considering bringing Android apps to the Windows Phone ecosystem. And today, you can finally experience Android Apps on Windows 10 Mobile but be warned, it's not an easy process and can force you to re-flash your device, so move ahead cautiously.
In the image at the top of this post, one user has Periscope up and running on his Lumia 920.
For starters, not all devices are supported at this time and make sure you are running the latest version of Windows 10 Mobile. Knowing you could damage your device, if you want to try out Android apps, read below.
Here is the list of supported devices:
  • Nokia Lumia 920
  • Nokia Lumia 925
  • Nokia Lumia 929 / Verizon Icon
  • Nokia Lumia 830
  • Nokia Lumia 930
  • Nokia Lumia 1520
  • Nokia Lumia 635 (1GB RAM variant)
  • Nokia Lumia 730
  • Nokia Lumia 820
  • Nokia Lumia 435
  • Nokia Lumia 928
If you have one of the above devices, here’s how to install the apps:
  • Download Android SDK’s ADB and wconnect tool from here.
  • Extract the files in the folder and Open the folder wconnect,then installIpOverUsbInstaller.msi and vcredist_x86.exe
  • Open the Windows 10 Mobile’s Settings page ->Update & Security > For Developers and enable Developers Mode, as well as Device Discovery
  • Open the extracted wconnect folder, open an elevated command prompt (Shift+right click > Open command window here)
  • Then you’ll need to connect to the phone — (USB method is recommended):
  • To Connect using USB, type wconnect.exe usb and hit enter
  • Then it’ll ask for the pairing code, enter the code and hit enter
  • Then navigate to the extracted adb folder and open an elevated command prompt
  • To make sure that your device is connected, type adb devices and hit enter to show the list of devices that are connected
  • Lastly, place the APK file that you want to install on the same directory (adb folder) and type in adb install APKNAME.apk (replace APKNAME with the APK file’s name)
  • That's it, then you can install the APKs.
Couple of things to keep in mind, obtaining APKs may not be legal in your area, so keep that in mind, also, this is highly experimental at this time and many users are reporting that this is causing their devices to be frozen and forcing a complete re-flash of the device. Do not try this on anything other than a development device.
But what this will allow you to run some Android apps on your phone but at this time, if they depend on a Google service, not surprisingly, they will not be functional on a Windows 10 Mobile device. But, seeing as users are already getting some apps up and running, shows that for Android developers, bringing their apps over to Windows 10 Mobile is going to be a trivial task.
While this move may sound like Microsoft is giving up on native app development for Windows 10 Mobile, it does solve the bigger issue of not having enough high quality apps on its mobile devices.

For many months, we had been reporting that Microsoft was considering bringing Android apps to the Windows Phone ecosystem. And today, you can finally experience Android Apps on Windows 10 Mobile but be warned, it's not an easy process and can force you to re-flash your device, so move ahead cautiously.
In the image at the top of this post, one user has Periscope up and running on his Lumia 920.
For starters, not all devices are supported at this time and make sure you are running the latest version of Windows 10 Mobile. Knowing you could damage your device, if you want to try out Android apps, read below.
Here is the list of supported devices:
  • Nokia Lumia 920
  • Nokia Lumia 925
  • Nokia Lumia 929 / Verizon Icon
  • Nokia Lumia 830
  • Nokia Lumia 930
  • Nokia Lumia 1520
  • Nokia Lumia 635 (1GB RAM variant)
  • Nokia Lumia 730
  • Nokia Lumia 820
  • Nokia Lumia 435
  • Nokia Lumia 928
If you have one of the above devices, here’s how to install the apps:
  • Download Android SDK’s ADB and wconnect tool from here.
  • Extract the files in the folder and Open the folder wconnect,then install IpOverUsbInstaller.msiand vcredist_x86.exe
  • Open the Windows 10 Mobile’s Settings page ->Update & Security > For Developers and enable Developers Mode, as well as Device Discovery
  • Open the extracted wconnect folder, open an elevated command prompt (Shift+right click > Open command window here)
  • Then you’ll need to connect to the phone — (USB method is recommended):
  • To Connect using USB, type wconnect.exe usb and hit enter
  • Then it’ll ask for the pairing code, enter the code and hit enter
  • Then navigate to the extracted adb folder and open an elevated command prompt
  • To make sure that your device is connected, type adb devices and hit enter to show the list of devices that are connected
  • Lastly, place the APK file that you want to install on the same directory (adb folder) and type in adb install APKNAME.apk (replace APKNAME with the APK file’s name)
  • That's it, then you can install the APKs.
Couple of things to keep in mind, obtaining APKs may not be legal in your area, so keep that in mind, also, this is highly experimental at this time and many users are reporting that this is causing their devices to be frozen and forcing a complete re-flash of the device. Do not try this on anything other than a development device.
But what this will allow you to run some Android apps on your phone but at this time, if they depend on a Google service, not surprisingly, they will not be functional on a Windows 10 Mobile device. But, seeing as users are already getting some apps up and running, shows that for Android developers, bringing their apps over to Windows 10 Mobile is going to be a trivial task.
While this move may sound like Microsoft is giving up on native app development for Windows 10 Mobile, it does solve the bigger issue of not having enough high quality apps on its mobile devices.
Source: http://www.neowin.net/news/it039s-now-possible-to-run-android-apps-on-windows-10-mobile