Xamarin: How and where to i specify design aspects? - android

I'm new to xamarin forms (but familiar with WPF) and want to create a rather simple material-design app (currently android-only, but want to add IOS support later).
Even after hours of googling I have no idea where to specify the app design.
I basically started with a Xamarin Forms Crossplatform Mobile App Project and used the Master-Detail template in Visual Studio. This provides me with three projects, the "xamarin", android and IOS projects (I will call them like this from now on). Background- and logic code is currently located in the xamarin project, aswell as the basic layout for the views (button definitions, etc.).
So how do I edit the styles of the buttons, content pages, etc. to match the material design (Background colors, shape, etc.)?
There seem to be two options:
1) Define colors, styles and themes in the Android project (Resources/values/colors.xml and styles.xml files).
2) Define colors, styles and themes in the Xamarin projects xaml files (App.xaml, [pages].xaml files).
Which of these options is the way to go? What do you recommend?
I assume to have more styling options available if going for 1), but then I will have to specify every style separately for android aswell as for IOS. If specifying it in the shared xamarin project, I will only have to do it once for all platforms.
Am i right?
What are pro's and con's / is there completely other way of doing this?

Setting your colors, styles, and themes in the App.xaml file of your "Xamarin" project is the recommended way when doing Xamarin.Forms projects and will probably be the best way to go. This will put all of your information in one place to allow easy editing and will allow you to reference the styles easily in your code/XAML.
I don't think it's noted in the docs, but you can also use Xamarin's OnPlatform setters to set different iOS and Android values.
Look here for info about global styles and here for information about OnPlatform.

Related

Can I externalize the Ionic2 components in another project?

I'm working on a project where one requirement is to use the Google's Material design. The other requirement is Angular2. Unfortunately the material design for NG2 isn't fully ready yet. Since in the past I've worked with Ionic2, I've seen that it has a huge library of components already set up with the material design (for android). I was wondering if there's some way to extract those components and re-use them inside another angular2 project...
Is it witchcraft? Thanks for any suggestion.
Is it a web project or a mobile project?
In any case you can't just extract a component, what you can do is use PWA Ionic 2 - PWA forum post, set you application mode to 'md' in you app.modules imports and then edit the remaining css to look more like material design

How to reference Android material icons from app?

I'm trying to use Android's material icons in a View from within my app. I can't seem to find an example anywhere of how to reference them. I can't imagine, for this standard set of icons, that I'm required to copy and paste them into my actual app under the res directory. Surely there must be a simpler way since 90% of Android apps are using the same drawables! What I'm looking for is something like:
<TextView
...
android:drawableLeft="???" />
Is it possible to do this and reference the drawable from some package that I import? Or do I actually have to copy all the icons I want to use into my application resources? That seems completely unnecessary to me.
The developer guide says they're named */drawable-{{density}}/ic_{{name}}_{{color}}_{{size}}dp.png but it's precisely the * which I would like to know (and I hope it's not myapp/res/drawable!).
You can try Android Material Design Icon Generator plugin for Android Studio, If you are using Android Studio. Link to the plugin development Git repo is here
It is Easy and convenient. You can go through the image set and get the name from the google material design official website and then, you search for it and you can add that one to your project without any hassel.
Yes, you have to copy all your icons to your res folder. It's been said by Google somewhere. The "Material Icons" website clearly is oriented towards that and it makes it easier. One important reason to do this is that you'll want the icons to work not only in Lollipop, but also in previous Android versions.

How to use Android Design Pack provided by Google with Eclipse

I am trying to use these cool set of add-ins that Google provides in the link below
http://developer.android.com/design/downloads/index.html
But I cannot understand how to integrate it with eclipse so that they are available directly as a drag and drop. Do you have any idea how to use it?
You cannot integrate into eclipse, because it only allows valid Views "linked" to your project (directly or from a library). These are just sources to make drawables. You have to create your own drawables from it. But if you're interested in holo theme, you should check the sources of android (API 11+). If you've installed, you can find it at /platforms/android-11/data/res/ . Maybe you find useful the HoloEverywhere project. But you can use the Action Bar Icon Pack, you have to copy the appropriate drawables to your project and when you drag an ImageView into the layout editor, you can choose the source from a dialog or you can enter path in xml.
EDIT
Forgot to mention, there is a very great online tool which will generate holo drawables with custom colors here.
After some digging up and watching Google IO 2012 videos on Design, the Design pack is actually a template for designers to create a UI before actually developing it. It contains a pack of action bar icons (These can be imported into your project), bunch of stencils that can be used with Adobe products to create an initial mock ups of your applications. Though, they cannot be directly imported into eclipse and used (as they are actually available already with the SDK), its a good guide to start design instead of actually coding and re-inventing afterwards.

Two android apps with same logic but different styles

I have two Android apps with different icon and color themes but that share the same activities, layout and logic. Any idea how to manage these apps? It would be counter-productive to duplicate the logic and layouts. There should be only one instance of layout, logic, etc.
this is the perfect scenario for using an Android library project.
Use your project as library (check the properties) and let the two implementing projects use that library.
You can re-use code and resources like layouts, images etc. across multiple applications using a library project, linked to from your different customised projects.
In Android Studio, you can harness the power of the gradle build system and easily create a solution for your problem. Check out http://tulipemoutarde.be/2013/10/06/gradle-build-variants-for-your-android-project.html

android custom fonts in xml

We can change fonts using java code as described here:
Roboto font in my android app
My question: Is there a way to specify the fonts in the xml layout file itself? Or better still, can we specify the font in the AndroidManifest.xml, so that it reflects across the app?
Thanks,
Rahim.
You can use a theme that contains all the styles you want to use in your app (included fonts). The use of the schema is declared in the manifest
http://developer.android.com/guide/topics/ui/themes.html
If you want to manage custom fonts without headache, I suggest you to use a library that handles the hard part, like caching the fonts in memory and allows to preview the display in the Layout Editor. Then you can focus on creating the styles for your titles or texts.
I have done such a library called Smart Fonts for Android.
It is easy to install with gradle, and it is well documented.
It is available on GitHub:
https://github.com/smart-fun/SmartFonts
enjoy!

Categories

Resources