This article was translated from Japanese by Claude Code.

I thought I’d trip over this again when I forget about it, so here’s a memo.
Premise#
<?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/some_id"
android:title="@string/some_menu_item_title"
android:actionLayout="@layout/some_action_layout"
app:showAsAction="always" />
</menu>When you have code like this, for some reason the text specified by title is displayed, but the layout specified by actionLayout is not displayed.
Solution#
android:actionLayout="@layout/some_action_layout"↑ Change this
↓ To this
app:actionLayout="@layout/some_action_layout"It’s described here: stackoverflow.com
What’s the Difference Between android: and app:?#
The android: prefix is used for specifying attribute values of UI provided by the Android SDK, while the app: prefix is basically used for specifying attributes on custom Views and the like. That much I understand. But custom namespaces are desired to be usable only when developers define custom Views, yet in practice, they’re also used for APIs provided by the Android platform, like the actionLayout specification in menu XML as in this case. Others include app:srcCompat.
When using APIs provided by the Android platform, when do you use android: and when do you use app:? I’d like to see consolidated guidance, but I haven’t found such a resource.
If anyone knows, I’d appreciate if you could tell me 🙏