Kyle Horkley
Kyle Horkley

Reputation: 1001

Why do I need to specifically target the android.support.design library?

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!

Upvotes: 0

Views: 107

Answers (3)

Sandro Machado
Sandro Machado

Reputation: 10205

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.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006644

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.

Upvotes: 2

Doon
Doon

Reputation: 3749

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.

Upvotes: -1

Related Questions