</pre><pre name="code" class="html">getActionBar().setDisplayHomeAsUpEnabled(true);// 设置返回的箭头
// 加标题背景及设置文字颜色
getActionBar().setBackgroundDrawable(
this.getBaseContext().getResources()
.getDrawable(R.drawable.actionbar_bg));
getActionBar().setDisplayShowHomeEnabled(false);
getActionBar().setTitle("凑热闹");
int titleId = Resources.getSystem().getIdentifier("action_bar_title",
"id", "android");
TextView title = (TextView) findViewById(titleId);
title.setTextColor(getResources().getColor(R.color.white));
title.setTextSize(20);
***********************
其他中加:
// 响应返回键的代码
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.empty, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
ExerciseSubFActivity.this.finish();
return true;
}
return super.onOptionsItemSelected(item);
}
Android中加标题的背景和文字并且添加返回
最新推荐文章于 2022-03-24 14:53:07 发布