How to reference Android material icons from app? - android

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.

Related

How do we create android application custom documentation for application flow?

Recently my team mates has started to work on an android application, which has more than 200 screens in an application.
In this case, I face one issue that when I need to explain the code or flow of screen to the other developer it would too much difficult. So I have to google to find the solution.
I am not much aware of the solution for android. In javascript, I have used jsDoc or swagger for API documentation, which offered a great way.
But in android, I unable to find the solution for coding documentation and screen flow.
Do I need any design tool to explain screen flow and documentation of an android application?
Let me know if you need more details or explanation I shall update the question accordingly or improve my question.
There is no way to create an automated screen / state transition diagram. If you use the Navigation Architecture component, you can use the navigation editor which is similar to Apple's storyboards. This is helpful but often times doesn't cover everything.
In our projects we rely on tools like overflow.io to create and maintain the screen flow diagrams. We use either design files from sketch or Adobe XD or screenshots from our app. This is a very manual process.
Firstly Go to File -> Project Structure. Under the Platform Settings heading, add or select an Android Platform. Go to the Documentation Paths tab and make sure the path to your SDK's documentation folder is added there - it should be [SDK]\docs\reference, where [SDK] is the full path to your SDK installation.
If it is not found you can add it manually.
After it is completed, use Ctrl+F1 while your cursor is on the item you want to display help for.

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.

Whitelabel an app using Ant

So I will be white labeling an app soon. The whitelabel will simply be a replacement of graphics (with same name) and also some colors and string (.xml files). There will also be some config changes such as API keys etc.
I'm just wondering would it be possible to do this with ant. For example I could call ant company_a and ant company_b
Has anybody done this? Thanks.
We're white-labeling software a little bit different, just using Eclipse as our primary development environment:
The main application code goes into an actual Android library project - this includes all Activities, Fragments, layout XMLs and default graphics. Just about everything.
For every customer we create a dedicated APK project with a dedicated Package Name (also see Chris Stratton's comment to your question). This APK simply links the library above. It consists of nothing more than an AndroidManifest.xml referencing the necessary Activities, Services, etc.
Now we can customize nearly everything of the App very easily:
Replace a graphic: Simply add a new graphic resource to the APK project with the same name as the original one you want to replace.
Customize a string: Just add a new strings.xml that overwrites an existing definition
Customize layout: Overwrite a layout definition by simply using the same file name.
etc.
This is a very easy and efficient approach for us. It gives nearly unlimited possibilities with little maintenance effort and full Eclipse integration for development and debugging.
Building an Ant script on top of that should be pretty straight forward, too.

Which menu/status icons' guidelines should I follow for an app that will support Android 2.2 and later?

In the guidelines found in http://developer.android.com/guide/practices/ui_guidelines/index.html for menu and status icons, we have distinctive design approach for Android 2.2 and earlier and Android 2.3 and later.
My app is going to support Android 2.2 and later. I was thinking that i should follow the 2.3 and later guidelines.
Do you agree?
You can follow multiple styles by creating subfolders with the correct android version specifiers inside your res/ folder (e.g. drawable-v11 for API 11 - check the official documentation here). So I suggest supporting multiple styles.
This is obviously a bit more work. To make this easy for standard icons like notifications, check out the Android Asset Studio. This is a small webapp that creates these icons to your specifications and builds a zip with the multiple styles, already sorted into the different res/ subfolders.
On thing you could do is include assets for both builds, and at run time, figure out if you're on 2.2 or 2.3, and show the appropriate assets. This can be done with build.version or this method for earlier releases.
Of course, if you want multiple icons, I don't believe this method would work, as that needs to be build into the android manifest.

Why shouldn't I use the menu icons provided by the OS?

I would like to use some of the default menu icons provided by the Android OS.
The XML would be something like this:
<item android:id="#+id/menu_refresh"
android:icon="#android:drawable/ic_menu_refresh"
android:title="#string/menu_refresh" />
But the documentation says this is unadvised.
Warning: Because these resources can
change between platform versions, you
should not reference these icons using
the Android platform resource IDs
(i.e. menu icons under
android.R.drawable).
I thought the whole point of using the default icons is because the design does change from OS to OS. By using the default icons, your app will look and feel appropriate for the OS it's running on. So what is so bad about using the default icons? It seems like not using the default icons would hurt the appearance of the app.
The problem is that you are adding in a dependency that google does not guarantee will be static.
The names of these icons could change, the size could change and become incompatible with your app.
If you want icons to be the same as the current google ones, you can use the ones available here
It is very possible that some configuration of android will NOT have these resources read: HTC Sense, Samsung TouchWiz.
What you can do is find the drawables you want in your sdkFolder/platforms/platform-#/data/res/ and drop them into your project. Then reference them as you would any normal resources (#drawable/icon).
IMO, in practice you can use menu icons provided by Android OS, as long you use only the icons provided by OS for all your menu items. If you need another icon (say, refresh), you will need to copy images for other icons as well. Otherwise, if you mix your own and OS icons, visual styles may differ significantly on some devices.
I really can't think of a reason not to other than what if your operation does something more than slightly different from the associated action the OS does. For an exagerated instance, if you had your trash can button be the place where you created new widgets. But I figure if you are keeping the operations similar to those of the OS, then you are fine. In fact I agree with you, it may even look better for the app.
The problem is with the "customizations" each carrier or factory makes to the OS, so you cannot assume they are present or match the use. Anyhow,if you like them, you might just copy them to your drawables, as they will look standard no matter the customizations.
Also it can vary from android version to another android version.. So it would be best to include your own set of icons

Categories

Resources