为API 21倾销AppCompat [英] Dumping AppCompat for API 21
问题描述
因此,我正在创建一个应用程序,它是Lollipop 5.0 API 21及更高版本,对支持较旧的设备的兴趣为零.在使用Material Design(例如UI元素&布局(侧边栏又名导航栏,墨水等)?当将其剥离时,当我尝试脱离AppCompat内容时,经常会遇到崩溃.将活动类型从AppCompat更改为Normal,我最终遇到了关于诸如协调器布局之类的布局类型依赖性的问题.
So I'm creating an app that is Lollipop 5.0 API 21 and up with zero interest in supporting older devices. Do I still need the appcompat library when using Material Design like UI elements & layouting (sidebar aka nav bar, ink, etc) ? When stripping it down I often encounter crashes when trying to move away from the AppCompat stuff. Changing activity types from the AppCompat one to the Normal one, I end up with problems regarding dependencies on layout types like the coordinator layout that aren't there.
我还是Android的新手,这非常令人困惑,因为我的主题目前处于appcompat主题与&当我尝试从模板之一更改材料设计时.
I'm still new to android and this is very confusing, as my theme is currently in limbo somewhere between the appcompat theme & material design when I tried to change it from one of the template.
我已经读到这是一个android studio问题,因为无论您设置的依赖项是什么,它始终使用appcompat.最低API级别.强迫您手动覆盖每个隐式隐藏的appcompat调用.
I've read that this is an android studio issue because it always uses appcompat regardless of your set dependencies & minimum API levels. Forcing you to manually override every implicit hidden appcompat call.
在尝试转储AppCompat时,我需要做些什么更改以使这种情况发生?清单,活动,菜单,布局,样式?似乎触及了所有这些东西.如果要在不使用Appcompat的情况下排他性使用,您是否仍然需要v21文件夹,或者它将获取默认文件夹?
When trying to dump AppCompat, what changes to I need to do to make that happen ? Manifest, Activities, Menus, Layout, Styles ? It seems to touch all these things. If going exclusive without Appcompat, do you still need the v21 folders or will it grab the default ones ?
推荐答案
在使用Material Design(例如UI元素和&布局(侧边栏又名导航栏,墨水等)?
Do I still need the appcompat library when using Material Design like UI elements & layouting (sidebar aka nav bar, ink, etc) ?
如果使用的是Design Support库之外的类,例如NavigationView
,则通常需要使用appcompat-v7
和AppCompatActivity
.截至2016年5月上旬,Google尚未交付可与Theme.Material
一起使用的设计支持库类似物.您也许可以找到其中一些小部件的第三方库替代品,而经验丰富的Android开发人员有时可以交叉移植"这些组件以消除appcompat-v7
依赖性.
If you are using classes out of the Design Support library, such as NavigationView
, you generally need to use appcompat-v7
and AppCompatActivity
. As of early May 2016, Google has not shipped a Design Support library analogue that works with Theme.Material
. You may be able to find third-party library replacements for some of those widgets, and seasoned Android developers can sometimes "cross-port" these components to eliminate the appcompat-v7
dependencies.
我已经读到这是一个android studio问题,因为无论您设置的依赖项是什么,它始终使用appcompat.最低API级别.强迫您手动覆盖每个隐式隐藏的appcompat调用.
I've read that this is an android studio issue because it always uses appcompat regardless of your set dependencies & minimum API levels. Forcing you to manually override every implicit hidden appcompat call.
Android Studio真正关心的唯一地方是appcompat-v7
在新活动向导中,您不必使用它.
The only place that Android Studio really cares about appcompat-v7
is in the new-activity wizards, which you do not have to use.
当尝试转储AppCompat时,我需要做些什么更改以使这种情况发生?清单,活动,菜单,布局,样式?
When trying to dump AppCompat, what changes to I need to do to make that happen ? Manifest, Activities, Menus, Layout, Styles ?
很难抽象地回答.您需要:
That is difficult to answer in the abstract. You would need to:
-
停止使用Design Support库小部件和容器
Stop using Design Support library widgets and containers
停止从AppCompatActivity
将菜单资源中的app:
属性更改为等效的android:
Change your app:
attributes in your menu resources to their android:
equivalents
将主题更改为不使用Theme.AppCompat
如果在不使用Appcompat的情况下排他性使用,您是否仍需要v21文件夹,或者它将获取默认文件夹?
If going exclusive without Appcompat, do you still need the v21 folders or will it grab the default ones ?
-v21
资源目录未绑定到appcompat-v7
.它们仍将在21级以上的API设备上使用.
-v21
resource directories are not tied to appcompat-v7
. They will still be used, on API Level 21+ devices.
这篇关于为API 21倾销AppCompat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!