There is an app for API21+ (Material Design).
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<application
...
android:theme="@style/AppTheme">
styles.xml:
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
menu_item_add.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_save"
android:enabled="false"
android:icon="@drawable/ic_action_add_entry"
android:title="@string/action_add"
app:showAsAction="always"/>
<item
android:id="@+id/action_settings"
android:title="@string/action_settings"
app:showAsAction="never"/>
</menu>
Menu is inflated inside Activity
:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_item_add, menu);
return true;
}
Android Studio preview show, that it supposed to look like:
But the "Add" is hidden, the menu item is shown along with "Settings" inside popup.
Question:
- How to make sure the icon is shown?
EDIT:
It seems my problem is similar to this one:
app:showAsAction vs android:showAsAction
However my Activity
looks like:
...
public class EntryAddActivity extends Activity {
...
So I don't understand why am I getting message about appcompat.