【发布时间】:2013-07-11 23:34:08
【问题描述】:
现在我的活动标题在左侧显示为< Title,然后另一个菜单项显示在右侧。我想将我的标题居中并省略<。我怎么做?我正在使用我调用的典型菜单
public boolean onOptionsItemSelected(MenuItem item)
和
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.yesterday, menu);
return true;
}
编辑:
我设法让它显示使用
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_yesterday);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.yesterday_title_bar);
yesterday_title_bar 是一个相对布局
但它显示了视图高度的一半。所以我创建了以下样式。但是当我在清单中应用样式时。清单说它找不到资源。
<style name="CustomWindowTitleBackground">
<item name="android:background">#323331</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">65dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
清单:
<activity
android:name="com.company.YesterdayActivity"
android:theme="@android:style/CustomTheme" >
</activity>
【问题讨论】:
-
研究为
ActionBar扩展自定义布局。 -
我试过了。它说不能将自定义与其他功能混合。
-
android.util.AndroidRuntimeException: You cannot combine custom titles with other title features如何关闭它? -
你可以在这里发布你的自定义样式 xml 吗?
-
@user2045570 我发布风格
标签: android android-layout android-actionbar statusbar