現在我的活動標題顯示在左側,爲< 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
是一個RelativeLayout的顯示
但它顯示了視圖高度的一半。所以我創造了以下風格。但是當我在清單中應用風格時。清單說它找不到資源。
<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'自定義佈局。 – adneal
我試過了。它說不能將自定義與其他功能混合使用。 –
'android.util.AndroidRuntimeException:您不能將自定義標題與其他標題功能組合'我如何關閉它? –