Xamarin.Forms: Styling is not the same for UWP, WinPhone - xamarin

In Android looks like OK. But UWP looks ugly. Font-size is too big. Controls are too big.
But UWP app is bad:
Is it possible to make it a little bit the same. I understand it has different theme. But how I can overide it? Change font-size for whole app?

Checkout OnPlatform - it allows you to specify different values for different platforms. If you create some styles for your controls you can set the font size depending on platform using this trick.
There's an example of using OnPlatform on the Xam developer site, half way down this page:
https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/essential_xaml_syntax/

Related

Enforcing theme for a particular Xamarin application

In my Xamarin project (Xamarin 4.8) there are many pages with complex structure. Also there are many bitmap resources, designed for white backgrounds etc.
When user sets Dark theme on the iOS, appearance of pages become weird and unusable. On Android the application looks as nothing was changed.
For now I have no time, to set manually color properties on every control on every page and I would like to enforce light theme for the application (Android and iOS platforms), to get a time to redesign the whole application later.
In an article I read that Xamarin 5 offers a way, putting this line of code into Application class:
App.Current.UserAppTheme = OSAppTheme.Light;
I tried this way (migrated project to Xamarin 5 and called this code), but it does not work. Application on iOS in the Dark theme looks unusable.
What options do I have on this point? Is there a relatively simple way to enforce Light theme for iOS applications?
As advised by #SushiHangover and #JackHua-MSFT into this answer I used the following approach and it worked (XCode 12.3):
Into the plist.info I should add the key UIUserInterfaceStyle with value Light. And that enforces Light theme for the application, regardless of what theme is set for the device.
Final xml code, that I added to plist.info looks like that:
<key>UIUserInterfaceStyle</key>
<string>Light</string>

Xamarin Forms NavigationPage Icon Sizes

I'm trying to create a navigation bar for my Xamarin Forms app. I'm adding some primary ToolbarItems which will have an icon associated with them using the following syntax:
ToolbarItems.Add(new ToolbarItem("Search", "ic_action_search.png", ActionSearch, ToolbarItemOrder.Primary));
I've searched everywhere but I cannot find the recommended images sizes for each platform (Android, iOS, UWP, Windows, and WinPhone).
Does anyone know what they should be?
A google search for "recommended tool bar icon sizes [Android|iOS|UWP] was very useful here.
iOS:
https://developer.apple.com/ios/human-interface-guidelines/graphics/custom-icons/
Android:
https://developer.android.com/guide/practices/ui_guidelines/icon_design_action_bar.html
UWP:
https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets
No good chart that I found for UWP as it is quite a bit more complex due to support of Tablets, Phones, and Desktop, but the needed info is in the guide above.

Obtaining target platform properties like background color and font size

The iOS and Android targets of Xamarin.Forms are visually quite different. To work around this gap:
Does Xamarin.Forms provides a class, which has getters for visual properties of the current target platform:
Background color
Font color
Font size of TableView TableIntent.Menu text
Font size of Label view text
...
You get the point: Obtain a full description of visual target platform properties.
Does the framework provide these values? Or do I have to compute them manually (and how)?
No, Xamarin.Forms does not expose those values. The only device specific information exposed is Color.Accent.
You can retrieve the information you need quite easily, and inject it in you Xaamrin.Forms project. XF provides a basic DI container: DependencyService

How to incorporate new look and feel in android?

I'm coming from a web development background. I'n order to change the look and feel of the app I simply apply a new css to get the look and feel.
How can I do this in android?
The only think I can see is stencils? But I don't quite understand stencils?
Can I simply get hold of some file(s)/images and add it to the resources a suddenly my app looks stunning?
I'm really confused on how to do this?
The CSS equivalent in Android are Styles and Themes. You can then apply a style of any of your components (i.e., have all your TextViews have a particular look). You may consider looking at the output of the Android Asset Studio (particularly the Android Action Bar Style Generator and the Android Holo Colors Generator tools) as examples of styles and themes.
All layouts in android are made in xml files under the res/layoutfolders, but it's not as simple as changing a css files. All these xml files are connected to Java classes, where there may also be some layout changes.
You can edit colors and themes quite easily but you need some experience in native android development if you want to know what you're doing.

Basic layout of appcelerator app

I creating my first appcelerator app and looking for some info on whether something is possible, and if so is it easy to implement.
I'm using Titanium SDK 2.0.1.
I'm trying to create a layout similar to the Stream window in the Google+ app for Android:
1: A large header (Can the navbar property of Ti.UI.createWindow be adjusted?)
2: Two tabs under the header (Would like to be able to adjust height of them if possible? Are there alternatives to Ti.UI.createTabGroup if this is not possible?)
The main content I can figure out easily enough I reckon.
Any examples or links on how to achieve this layout would be great.
Thanks
There is no way to do that type of NavBar in Android using the native Ti.UI.Window properties, but you can just create your own NavBar using a view and stick to the top of the window. For the tabs, I'd look at http://www.tomaspersson.com/2012/03/20/titanium-viewpager-module-now-available/ - I'm not sure it will have all the options you need, but it is a good starting point. Good luck!

Resources