假设您正在使用android.widget.Toolbar
,您正在寻找字幕。可以在XML中设置:
<Toolbar
android:subtitle="@string/your_string_here"
.../>
或使用代码:
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setSubtitle(R.string.your_string_here);
[如果您使用提供默认工具栏的AppCompat主题,则可以通过getSupportActionBar()
访问它。这将返回一个android.support.v7.app.ActionBar
(或等效的androidx
),但是语法相同:
ActionBar actionbar = getSupportActionBar();
actionbar.setSubtitle(R.string.your_string_here);