Difference between Android Framework widgets and their AppCompat version

好久不见. 提交于 2020-01-23 05:35:11

问题


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:

  • Difference between ListView and ListViewCompat
  • Difference between Button / AppCompatButton
  • Difference between ImageView / AppCompatImageView
  • Difference between EditText / AppCompatEditText
  • Difference between TextView / AppCompatTextView

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)


回答1:


AppCompat is support older version of android os like AppCompat-v7 is support from android 6.1.1 to android 2.6.0

for above reason they have created AppCompat classes of below widgets in this support library nothing more.

from Documentation

The full list of tint aware widgets available in appcompart

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?



来源:https://stackoverflow.com/questions/35009532/difference-between-android-framework-widgets-and-their-appcompat-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!