Joakim
Joakim

Reputation: 3294

Difference between Android Framework widgets and their AppCompat version

I have lately noticed that there are AppCompat versions of most View types in Android, for example ListView / ListViewCompat, Button / AppCompatButton etc.

For these more simple Views (not counting for example SwitchCompat), what are the difference between them and the Android Framework version? I have not found any documentation on this matter...

I'm interested in knowing the consequences of choosing either version and if there are any advantages in chosing one over the other.

Specifically:

I changed from normal to AppCompat versions with the expectation that colors would be used from the theme and look the same on Lollipop and pre-lollipop, but it rather had the opposite effect on some views (such as ListView)

Upvotes: 35

Views: 14107

Answers (2)

Dhaval Parmar
Dhaval Parmar

Reputation: 18978

AppCompat provides consistent UI support for older versions of APIs back to API v7. from Documentation

The full list of tint aware widgets available in appcompat

AppCompatAutoCompleteTextView
AppCompatButton
AppCompatCheckBox
AppCompatCheckedTextView
AppCompatEditText
AppCompatMultiAutoCompleteTextView
AppCompatRadioButton
AppCompatRatingBar
AppCompatSpinner
AppCompatTextView

ListViewCompat is subclass of ListView same others


edited:

why both class available in framework or How Android Support Library work?

Upvotes: 15

oiyio
oiyio

Reputation: 5925

If you use AppCompatActivity, then AppCompatImageView will automatically be used when you use ImageView in your layouts.

From the AppCompatImageView AppCompatEditText AppCompatButton

Button vs AppCompatButton

This will automatically be used when you use Button in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.

ImageView vs AppCompatImageView

This will automatically be used when you use ImageView in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.

EditText vs AppCompatEditText

This will automatically be used when you use EditText in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.

and the same rule is also valid for other appcompat views

Upvotes: 15

Related Questions