What is the difference between an AppCompat
view component and a standard/default view component?
For example, the difference between an AppCompatEditText
, and an EditText
, or between an AppCompatButton
and a Button
.
Looking at the developer docs for android.support.v7.widget
, the AppCompat
view components are described as "tint aware", but is this the only difference, and what exactly does this do?
AppCompat (aka ActionBarCompat) started out as a backport of the Android 4.0 ActionBar API for devices running on Gingerbread, providing a common API layer on top of the backported implementation and the framework implementation. AppCompat v21 delivers an API and feature-set that is up-to-date with Android 5.0.
No, you should always use AppCompat. This ensures that your app is already consistent across all API levels and you have access to all new APIs (such as using the Colored buttons, which was only introduced in API 23). Many other libraries, such as the Design Support Library also require use of AppCompat.
You might be using some features that are not compatible for older versions in your background drawable file. An AppCompatButton is simply a Button which supports compatible features on older versions of the platform, including: Allows dynamic tint of its background via the background tint methods in ViewCompat.
When you are using a Button
or an EditText
you are actually using AppCompatButton
and AppCompatEditText
. From the official documentation of the AppCompatEditText
.
A tint aware EditText. This will automatically be used when you use EditText in your layouts. You should only need to manually use this class when writing custom views
What is the difference between an AppCompat view component and a standard/default view component?
AppCompat View Component supports compatible features on older version of the platform.
the AppCompat view components are described as "tint aware", but is this the only difference, and what exactly does this do?
Although most of the AppCompatView only difference is it allows dynamic tint and background tint. Tint aware is not the only difference, each AppCompatView has its own differences, for example.
Allows textAllCaps style attribute up to Gingerbread.
Setting the popup theme using popupTheme.
You can dig down each view difference in Android docs.
However, as Sid / Docs says, you don't have to specify this on your layouts since it will automatically converted to AppCompat views. But, if you want to create custom view, you should use AppCompat Views, or else this bug will happens.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With