android – 当应用程序的minSdkVersion为21时,我的活动应该扩展什么?

android – 当应用程序的minSdkVersion为21时,我的活动应该扩展什么?,第1张

概述我是 Android和 Android Studio的新手.我创建了一个新项目,我已将minSdkVersion指定为21并将目标指定为23. 完成AS创建活动后,我发现默认情况下MainActivity正在扩展AppCompatActivity. 我读到了AppCompatActivity here 它表示它是使用support library *** 作栏功能的活动的Base类. 现在我的问题是: > 我是 Android和 Android Studio的新手.我创建了一个新项目,我已将minSdkVersion指定为21并将目标指定为23.

完成AS创建活动后,我发现默认情况下MainActivity正在扩展AppCompatActivity.

我读到了AppCompatActivity here

它表示它是使用support library *** 作栏功能的活动的Base类.

现在我的问题是:

>由于我的应用程序的minSdkVersion为21,为什么我需要我的活动来扩展AppCompatActivity?
>为什么AS使我的活动默认扩展AppCompatActivity?
>考虑到我的minSdkVerion,我的活动是否有必要扩展AppCompatActivity或只是扩展Activity就足够了?
>如果我的行为不扩展AppCompatActivity,我会想念什么?

任何解释都会非常有用.谢谢

解决方法 如果您使用 *** 作栏,我认为您应该扩展AppCompatActivity

Read more here

Beginning with AndroID 3.0 (API level 11),all activitIEs that use the default theme have an Actionbar as an app bar. However,app bar features have gradually been added to the native Actionbar over varIoUs AndroID releases. As a result,the native Actionbar behaves differently depending on what version of the AndroID system a device may be using. By contrast,the most recent features are added to the support library’s version of Toolbar,and they are available on any device that can use the support library.

For this reason,you should use the support library’s Toolbar class to implement your activitIEs’ app bars. Using the support library’s toolbar helps ensure that your app will have consistent behavior across the wIDest range of devices. For example,the Toolbar Widget provIDes a material design experIEnce on devices running AndroID 2.1 (API level 7) or later,but the native action bar doesn’t support material design unless the device is running AndroID 5.0 (API level 21) or later.

总结

以上是内存溢出为你收集整理的android – 当应用程序的minSdkVersion为21时,我的活动应该扩展什么?全部内容,希望文章能够帮你解决android – 当应用程序的minSdkVersion为21时,我的活动应该扩展什么?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1138148.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存