【问题标题】:appcompat for a project imported from eclipseappcompat 用于从 eclipse 导入的项目
【发布时间】:2015-03-13 05:18:07
【问题描述】:

我从 Eclipse 导入了一个没有问题的项目。迁移到 android studio 1.0.2 后,它告诉我因为 appcompat-v7 做一些更改(例如在菜单中我不应该使用 android:ShowAsIcon 等...)。

我有 1 个 MainActivity(扩展 Activity),它是片段的容器和几个在相关时可见的片段。

如果我理解正确,appcompat-v7 让我可以选择使用 API21 的新设计风格(例如高程),即使在 API 15(我的 minSDK)上也是如此?

是否应该仅仅因为 appcompat-v7 而扩展 ActionBarActivity 而不是 Activity?我在这里有点困惑。

【问题讨论】:

    标签: android android-studio android-appcompat material-design


    【解决方案1】:
    If I understand correctly, appcompat-v7 gives me the option to use the new 
    design styles of API21 (like elevation for example)
    

    appcompat21 允许您在 Pre-Lollipop 设备上支持材料设计。但它不支持旧设备上的提升。

    你可以从这个doc开始。

    Should MainActivity extends ActionBarActivity instead of Activity...
    

    是的。要应用 appCompat 样式,您必须扩展 ActionBarActivity。

    (for example in the menus I should not use android:ShowAsIcon etc...).
    

    使用 app:showAsIcon。

    <menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto" >
    
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        app:showAsAction="never"
        android:title="@string/action_settings"/>
    
    </menu>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-27
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 2014-02-13
      • 2011-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多