0

I'm fairly new to Android development, so I apologize beforehand. I'm a bit confused on the new Android support library. How come I can use <EditText> just fine, but in order to use <TextInputLayout>, I need to use <android.support.design.widget.TextInputLayout>? Thanks!

Kyle Horkley
  • 911
  • 1
  • 9
  • 23
  • Dear anonymous downvoter, can you please explain why my question was downvoted? What can I do to improve my question? – Kyle Horkley Jun 05 '15 at 22:47

3 Answers3

2

LayoutInflater, if it encounters what looks like a bare class name, will look in a couple of well-known packages for that class, such as android.widget and android.view. Any View not in one of those packages — such as android.support.v4.view.ViewPager — has to have a fully-qualified class name as the XML element name for LayoutInflater to find it.

All public classes from the Android Support libraries all use android.support as the base of their package name, to help distinguish them from classes that would be in device firmware. Hence, everything from the Android Support libraries, when used in resources, has to have fully-qualified class names.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ah, that makes sense. My question is, why did things like the paper-fab move to the android support library and not just be added to android.widget? – Kyle Horkley Jun 05 '15 at 22:46
  • 2
    @InfiniTech: They are backwards-compatible to older devices. Google *could* have added them natively to Android M (and still might) and just have backwards-compatible ones in the support library. However, I get the sense that they're leaning more in the direction of putting more of this stuff in libraries, so there's a consistent implementation across all Android versions, and so it can be updated more frequently than Android devices get updated. – CommonsWare Jun 05 '15 at 23:54
0

Android from version to version introduces new design concepts and widgets. The objective of the Android Support Libraries is to bring the new features to the older android versions. For example, in Android 4.X the design paradigm is Holo and in the Android 5.X the design paradigm is the Material Design. So in Android 5.X new widgets were added like CardsView so to this widgets be available on the older devices google have released the Android Design Compatibility Library. In resume, if you are supporting older android versions you should always use the support libraries to maintain the compatibility with the older versions of the android.

Sandro Machado
  • 9,921
  • 4
  • 36
  • 57
-1

From the docs:

The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level.

Doon
  • 3,339
  • 5
  • 25
  • 31