Difference between Android Framework widgets and their AppCompat version

前端 未结 2 867
遇见更好的自我
遇见更好的自我 2021-02-18 21:50

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

相关标签:
2条回答
  • 2021-02-18 22:11

    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?

    0 讨论(0)
  • 2021-02-18 22:22

    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

    0 讨论(0)
提交回复
热议问题