I given my application target as 21. So I can use the Material Design API's. But when I run the same on older devices whether I have to define different layout or theme or how it could me.
And also I have read the official document Maintaining Compatibility.
But still I was not clear to use the material theme on android devices less than 5 os.
And also where can I find the Android 5 related XML tags. And how the same tags applied when running on devices less than 5.
Please help me on this. Thanks in advance.
There are few library's to achieve the Material Design applicable to an earlier platforms less than API-21.
An example of such library is this one:
https://android-arsenal.com/details/1/1156. You can look on Android Arsenal for more library's like this.
Also this blog-post from Chris Banes is about Material Design on older platforms, I recommend that you read it: https://chris.banes.me/2014/10/17/appcompat-v21/. I hope it will be helpful for reduce design complexity.
Related
How to use Material Design on Android < 5? I added app.gradle to app/App_Resources/Android. This is what I have in there:
dependencies {
compile "com.android.support:appcompat-v7:21.0.+"
compile "com.android.support:design:23.2.1"
}
But still no luck getting Material Design slider and textfield. Could someone give precise instructions on how to add Material Design in NativeScript apps. Better a link to a repo with an example. Especially I'm interested in slider and textfield elements. Thanks.
Based on the guidance in developer.android.com here :
To use material design in your Android apps, follow the guidelines defined in the material design specification and use the new components and functionality available in Android 5.0 (API level 21) and above.
So basicly the native API is supporting Material design with version 5 and above so you can't implement it on lower versions.
Check also this link for further information about maintaining compatibility in different android versions.
EDIT: There are many plugins that are bringing material-design functionallity in NativeScript (for example cardview) - however notice that material design is more concept based on different rules so one technique can be considered material desing if used in place and anti-material if used wrong..
I want to use Material Design in different devices including(i.e) Android 5.1 and Android 4.4.2.
So, after 5.0 android uses Material by default. But what about other devices?
Where I can get samples of such project? How to implement Button, side K and FAB.
Actually, what is the best and common way to implement material? I know that there are some libs to handle my task, but maybe there is the better way.
Please help me to figure out this issue.
Thanks.
You have to use AppCompat Library v21 for Material Design in Pre-Lollipop Device.
http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html
Additional, want to include ActionButton, Collapsible Toolbar, Floating EditText etc. are available with Design Support Library by Android Developers.
http://android-developers.blogspot.com/2015/05/android-design-support-library.html
You can use the AppCompact support library for that.
http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html
Everything I'm reading so far about backwards compatibility with material design indicates that I have to maintain two separate sets of layout files if I want to use any material design features and maintain backward compatibility, one for 21+, and one for pre-21. Needless to say, this really sucks. Every time I want to change something in the UI, I have to change it twice. Am I correct in this, or is there a cool workaround I have not found?
It seems that an alternative is to set all the material design attributes in Java instead of XML, wrapped in a check against the current SDK version. I would consider this pretty ugly, but it might be better than duplicating layouts. Maybe a clever way to hide it away would make it more tolerable.
I can't think of anything other than these two bad solutions - has anyone found something better?
ianhanniballake is right, you can just leave the new tags in the file. I was basing my ire on this from the documentation:
If the layouts that you design according to the material design
guidelines do not use any of the new XML attributes introduced in
Android 5.0 (API level 21), they will work on previous versions of
Android. Otherwise, you can provide alternative layouts. You can also
provide alternative layouts to customize how your app looks on earlier
versions of Android.
Create your layout files for Android 5.0 (API level 21) inside
res/layout-v21/ and your alternative layout files for earlier versions
of Android inside res/layout/. For example, res/layout/my_activity.xml
is an alternative layout for res/layout-v21/my_activity.xml.
Which I think clearly says to use new attributes you have to duplicate your files. It seems that is not the case after all. Thanks.
I'm new at material design. I'm working on some projects and I want to use the material design. But I cannot find any source or sample for components. Is there any code sample (especially animated circle loader)?
Thanks a lot!
There are tens (if not hundreds) samples regarding ways to implement Material Design, some of 'em even described how you could make it work for older versions of Android.
This blog post by Google's own Chris Banes regarding AppCompat v21 is a good place to start when you're also working on Android versions lower than Lollipop.
While this, still from Mr. Banes, thoroughly describe one of Lollipop's most famed API, Palette.
Moving on, this blog post would help you started with those shiny round buttons (or FABs) and, as a bonus, a trick to apply ripple effect to it.
I think those three links should be more than enough to get you started making Material apps - I've built mine and those three were my first guides. Sadly though, I can't find one that matches exactly with your Dribbble link. Then again, I doubt a widget such as those exists today. I've been wrong before though. :)
Hope this helped!
Learn more:
Modular and customizable Material Design UI components for Android
Git link:
https://github.com/material-components/material-components-android
Playstore link:
https://play.google.com/store/apps/details?id=io.materialdesign.catalog
Considering Android Design Guidelines announcement what is the best way to make apps which are compliant with them on Android 2.x phones? E.g. what is the best way to implement the ActionBar pattern?
ActionbarSherlock is a starting point. It includes the compatibility libraries from Google and comes provided as a project rather than JAR offering greater flexibility, should you need to alter anything. Version 4 is on the way which will also include ICS stuff.
As far as I am aware I believe ABS is backward compatible to 1.6, and makes use of the minSdkVersion and targetSdkVersion. It uses an extended version of the holo theme to create a light and dark version that includes the extra ActionBar goodness, which in turn you can extend to style your app.
I recorded a tutorial on YouTube to get people started.
I think it's better to use the compatibilty libraries directly, instead of another library based on those. Additionally, refer to the Google I/O App as stated at the bottom of the first link I gave. You can find the best practices about implementing a UI for several devices with compatibility libraries.
I found ActionBarSherlock to be pretty good. It will emulate ActionBar on older devices and use the native one on modern ones. It's an extension to Android compatibility library - so you will also get fragments and other ICS stuff.