Android 拆分 ActionBar 不起作用

Android split ActionBar not working

我是 android 的新手...我想要一个简单的 activity,在所有教程中都有一个底部操作栏,它提到

有一种方法
android:uiOptions=”splitActionBarWhenNarrow”

但即使我添加了它也无法在平板电脑或小型设备上运行

 <meta-data android:name="android.support.UI_OPTIONS"
                android:value="splitActionBarWhenNarrow" />
        </activity>

这是我的manifest.xml

 <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        >
        <activity
            android:name=".launchActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:uiOptions="splitActionBarWhenNarrow"
            android:name=".MainActivity"
           >
            <meta-data android:name="android.support.UI_OPTIONS"
                android:value="splitActionBarWhenNarrow" />
        </activity>
        <activity
            android:name=".DisplayMessageActivity"
            android:label="@string/title_activity_display_message" >
        </activity>


        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
    </application>

构建文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "xxxxxxx"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Android 5.0 的默认主题(Theme.Material)不支持拆分操作栏。 appcompat-v7 操作栏也不再向后移植,尽管它曾经是。

您的选择是切换到基于 Theme.Holo 的主题,将您自己的栏放在屏幕底部(例如 Toolbar),或者简单地重新设计您的 UI 以避免拆分操作栏。

我完全同意@CommonsWare

我只是加个备注。

If you build your app only for Lolipop(5.0) or higher(for now) the action bar may be represented by any Toolbar widget within the application layout. You can align components(also split them) inside since you are want.