You can't do this. Or rather, you can't do this with the default Activity apis, doing so involves significant hackery.
If you really want to do this, here is some almost working code, that I admitadely didn't actually run, but that should put you on the right path.
// Find the View you want to represent the complete title subtitle combination.
// As well as the individual views for title and subtitle
View groupedView = findTheTitleBarView();
View subTitleView = propbablyAChildOfGroupedView;
View titleView = propbablyAChildOfGroupedView;
ViewCompat.setAccessibilityDelegate(groupedView, object : AccessibilityDelegateCompat() {
override fun onInitializeAccessibilityNodeInfo(
host: View?,
info: AccessibilityNodeInfoCompat?
) {
info?.text = subTitleView.text() + " " + titleView.text();
super.onInitializeAccessibilityNodeInfo(host, info)
}
})
// Ensure the children of those views are not individually focusable.
titleView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
subtitleView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
This is not a reliable way of accomplishing this. The only reliable way to do this would be to build your own title bar. The Android OS can override whatever AccessibilityDelegate you set whenever it wants. Unfortunately there is no Android API supported way to do this!