我已经和ActionBar合作了一段时间,但它的定制工作却一直受挫。我也一直在玩ActionBarSherlock和ActionBarCompat,但最后还是到了后者。
我看到很多应用程序将最左边的向上按钮和标题组合成一个ActionBar上的一个可点击按钮。如何在不为ActionBar提供自定义布局的情况下实现这一目标?这是一种仅自定义向上按钮以包含标题的方法吗?
提前致谢!
答案 0 :(得分:1)
向上按钮是ImageView
非按钮。所以你不能使用setText();
您可以将带有文本的图像设置为该ImageView。
示例代码:
getActionBar().setDisplayShowHomeEnabled(true);
getActionBar().setIcon(R.drawable.YourImage);
OR
getActionBar().setDisplayShowHomeEnabled(true);
ImageView imgHome=(ImageView)findViewById(android.R.id.home);
imgHome.setImageResource(R.drawable.YourImage);