迁移主原文:https://blog.csdn.net/dandelionela/article/details/102976961 # 【AS-AndroidX】AndroidX的迁移 #
------------------------------------------------------------------------------------------------------
常用控件前后对比:
Support Library Class | AndroidX Class | |
223 | android.support.constraint.ConstraintLayout | androidx.constraintlayout.widget.ConstraintLayout |
32 | android.support.v7.widget.CardView | androidx.cardview.widget.CardView |
27 | android.support.v7.widget.RecyclerView | androidx.recyclerview.widget.RecyclerView |
22 | android.support.v7.widget.Toolbar | androidx.appcompat.widget.Toolbar |
17 | android.support.v4.view.ViewPager | androidx.viewpager.widget.ViewPager |
16 | android.support.design.widget.AppBarLayout | com.google.android.material.appbar.AppBarLayout |
16 | android.support.design.widget.CoordinatorLayout | androidx.coordinatorlayout.widget.CoordinatorLayout |
11 | android.support.v4.widget.SwipeRefreshLayout | androidx.swiperefreshlayout.widget.SwipeRefreshLayout |
10 | android.support.design.widget.FloatingActionButton | com.google.android.material.floatingactionbutton.FloatingActionButton |
8 | android.support.v4.widget.DrawerLayout | androidx.drawerlayout.widget.DrawerLayout |
4 | android.support.design.widget.TabLayout | com.google.android.material.tabs.TabLayout |
4 | android.support.design.widget.CollapsingToolbarLayout | com.google.android.material.appbar.CollapsingToolbarLayout |
3 | android.support.constraint.Guideline | androidx.constraintlayout.widget.Guideline |
2 | android.support.design.widget.NavigationView | com.google.android.material.navigation.NavigationView |
2 | android.support.v4.widget.NestedScrollView | androidx.core.widget.NestedScrollView |
1 | android.support.v4.app.FragmentTabHost | androidx.fragment.app.FragmentTabHost |
0 | android.support.v7.widget.SwitchCompat | androidx.appcompat.widget.SwitchCompat |
0 | android.support.v4.view.PagerTabStrip | androidx.viewpager.widget.PagerTabStrip |
0 | android.support.v4.view.PagerTitleStrip | androidx.viewpager.widget.PagerTitleStrip |
常用类前后对比
Support Library class | AndroidX class | |
113 | android.support.v7.app.AppCompatActivity | androidx.appcompat.app.AppCompatActivity |
82 | android.support.v4.app.Fragment | androidx.fragment.app.Fragment |
73 | android.support.annotation.NonNull | androidx.annotation.NonNull |
71 | android.support.annotation.Nullable | androidx.annotation.Nullable |
67 | android.support.v7.widget.RecyclerView | androidx.recyclerview.widget.RecyclerView |
28 | android.support.v7.widget.LinearLayoutManager | androidx.recyclerview.widget.LinearLayoutManager |
26 | android.support.v4.view.ViewPager | androidx.viewpager.widget.ViewPager |
26 | android.support.constraint.ConstraintLayout | androidx.constraintlayout.widget.ConstraintLayout |
23 | android.support.v7.app.ActionBar | androidx.appcompat.app.ActionBar |
20 | android.support.v7.widget.Toolbar | androidx.appcompat.widget.Toolbar |
18 | android.support.v4.app.ActivityCompat | androidx.core.app.ActivityCompat |
17 | android.support.v4.content.ContextCompat | androidx.core.content.ContextCompat |
15 | android.support.v4.app.FragmentManager | androidx.fragment.app.FragmentManager |
15 | android.support.v7.app.AlertDialog | androidx.appcompat.app.AlertDialog |
12 | android.support.v4.app.FragmentPagerAdapter | androidx.fragment.app.FragmentPagerAdapter |
10 | android.support.design.widget.FloatingActionButton | com.google.android.material.floatingactionbutton.FloatingActionButton |
8 | android.support.v7.widget.GridLayoutManager | androidx.recyclerview.widget.GridLayoutManager |
7 | android.support.v4.widget.SwipeRefreshLayout | androidx.swiperefreshlayout.widget.SwipeRefreshLayout |
7 | android.support.v4.content.FileProvider | androidx.core.content.FileProvider |
6 | android.support.annotation.RequiresApi | androidx.annotation.RequiresApi |
5 | android.support.design.widget.CollapsingToolbarLayout | com.google.android.material.appbar.CollapsingToolbarLayout |
5 | android.support.v4.app.FragmentTransaction | androidx.fragment.app.FragmentTransaction |
5 | android.support.v4.view.PagerAdapter | androidx.viewpager.widget.PagerAdapter |
4 | android.support.design.widget.TabLayout | com.google.android.material.tabs.TabLayout |
4 | android.support.v4.widget.DrawerLayout | androidx.drawerlayout.widget.DrawerLayout |
4 | android.support.annotation.IdRes | androidx.annotation.IdRes |
4 | android.support.v7.widget.DividerItemDecoration | androidx.recyclerview.widget.DividerItemDecoration |
4 | android.support.v4.app.FragmentStatePagerAdapter | androidx.fragment.app.FragmentStatePagerAdapter |
3 | android.support.design.widget.NavigationView | com.google.android.material.navigation.NavigationView |
3 | android.support.design.widget.Snackbar | com.google.android.material.snackbar.Snackbar |
3 | android.support.v7.widget.StaggeredGridLayoutManager | androidx.recyclerview.widget.StaggeredGridLayoutManager |
3 | android.support.annotation.RequiresPermission | androidx.annotation.RequiresPermission |
3 | android.support.v4.view.GravityCompat | androidx.core.view.GravityCompat |
3 | android.support.v4.app.NotificationCompat | androidx.core.app.NotificationCompat |
3 | android.support.annotation.ColorInt | androidx.annotation.ColorInt |
3 | android.support.v7.widget.CardView | androidx.cardview.widget.CardView |
2 | android.support.design.widget.AppBarLayout | com.google.android.material.appbar.AppBarLayout |
2 | android.support.v4.widget.NestedScrollView | androidx.core.widget.NestedScrollView |
2 | android.support.v7.widget.AppCompatTextView | androidx.appcompat.widget.AppCompatTextView |
1 | android.support.v7.widget.SwitchCompat | androidx.appcompat.widget.SwitchCompat |
1 | android.support.design.widget.CoordinatorLayout | androidx.coordinatorlayout.widget.CoordinatorLayout |
1 | android.support.v4.view.ViewCompat | androidx.core.view.ViewCompat |
1 | android.support.v7.widget.helper.ItemTouchHelper | androidx.recyclerview.widget.ItemTouchHelper |
1 | android.support.v4.app.FragmentTabHost | androidx.fragment.app.FragmentTabHost |
1 | android.support.v4.app.FragmentActivity | androidx.fragment.app.FragmentActivity |
1 | android.support.annotation.DrawableRes | androidx.annotation.DrawableRes |
1 | android.support.v4.view.MotionEventCompat | androidx.core.view.MotionEventCompat |
1 | android.support.v7.widget.AppCompatEditText | androidx.appcompat.widget.AppCompatEditText |
0 | android.support.annotation.LayoutRes | androidx.annotation.LayoutRes |
0 | android.support.v7.app.AppCompatDelegate | androidx.appcompat.app.AppCompatDelegate |
0 | android.support.v7.widget.DefaultItemAnimator | androidx.recyclerview.widget.DefaultItemAnimator |
0 | android.support.v4.app.DialogFragment | androidx.fragment.app.DialogFragment |
0 | android.support.v4.util.Pair | androidx.core.util.Pair |
0 | android.support.v4.view.OnApplyWindowInsetsListener | androidx.core.view.OnApplyWindowInsetsListener |
0 | android.support.v4.view.WindowInsetsCompat | androidx.core.view.WindowInsetsCompat |
0 | android.support.v4.content.LocalBroadcastManager | androidx.localbroadcastmanager.content.LocalBroadcastManager |
0 | android.support.v4.os.EnvironmentCompat | androidx.core.os.EnvironmentCompat |
0 | android.support.constraint.Guideline | androidx.constraintlayout.widget.Guideline |
0 | android.support.v4.view.PagerTabStrip | androidx.viewpager.widget.PagerTabStrip |
0 | android.support.v4.view.PagerTitleStrip | androidx.viewpager.widget.PagerTitleStrip |
0 | android.support.annotation.IntDef | androidx.annotation.IntDef |
0 | android.support.annotation.Size | androidx.annotation.Size |
0 | android.support.annotation.StringRes | androidx.annotation.StringRes |
0 | android.support.multidex.MultiDex | androidx.multidex.MultiDex |
0 | android.support.multidex.MultiDexApplication | androidx.multidex.MultiDexApplication |
0 | android.support.v4.view.GestureDetectorCompat | androidx.core.view.GestureDetectorCompat |
0 | android.support.v4.view.VelocityTrackerCompat | androidx.core.view.VelocityTrackerCompat |
0 | android.support.v4.view.ViewConfigurationCompat | androidx.core.view.ViewConfigurationCompat |
0 | android.support.v4.widget.ScrollerCompat | androidx.core.widget.ScrollerCompat |
0 | android.support.v4.widget.TextViewCompat | androidx.core.widget.TextViewCompat |
0 | android.support.v7.appcompat.R | androidx.appcompat.R |
0 | android.support.v7.widget.AppCompatCheckBox | androidx.appcompat.widget.AppCompatCheckBox |
0 | android.support.v7.widget.AppCompatImageView | androidx.appcompat.widget.AppCompatImageView |
以下为常用Databinding | ||
-1 | android.databinding.ViewDataBinding | androidx.databinding.ViewDataBinding |
-1 | android.databinding.ObservableField | androidx.databinding.ObservableField |
-1 | android.databinding.BaseObservable | androidx.databinding.BaseObservable |
-1 | android.databinding.DataBindingUtil | androidx.databinding.DataBindingUtil |
-1 | android.databinding.ObservableBoolean | androidx.databinding.ObservableBoolean |
-1 | android.databinding.BindingAdapter | androidx.databinding.BindingAdapter |
-1 | android.databinding.Observable | androidx.databinding.Observable |
-1 | android.databinding.ObservableArrayList | androidx.databinding.ObservableArrayList |
-1 | android.databinding.ObservableArrayMap | androidx.databinding.ObservableArrayMap |
-1 | android.databinding.ObservableByte | androidx.databinding.ObservableByte |
-1 | android.databinding.ObservableChar | androidx.databinding.ObservableChar |
-1 | android.databinding.ObservableDouble | androidx.databinding.ObservableDouble |
-1 | android.databinding.ObservableFloat | androidx.databinding.ObservableFloat |
-1 | android.databinding.ObservableInt | androidx.databinding.ObservableInt |
-1 | android.databinding.ObservableList | androidx.databinding.ObservableList |
-1 | android.databinding.ObservableLong | androidx.databinding.ObservableLong |
-1 | android.databinding.ObservableMap | androidx.databinding.ObservableMap |
-1 | android.databinding.ObservableParcelable | androidx.databinding.ObservableParcelable |
-1 | android.databinding.ObservableShort | androidx.databinding.ObservableShort |