Android 如何在Actionbar sherlock中完全删除标题和图标?
我使用动作栏夏洛克,但我需要删除标题和图标从酒吧 我曾经Android 如何在Actionbar sherlock中完全删除标题和图标?,android,actionbarsherlock,Android,Actionbarsherlock,我使用动作栏夏洛克,但我需要删除标题和图标从酒吧 我曾经 getSupportActionBar().setDisplayShowHomeEnabled(false); getSupportActionBar().setDisplayShowTitleEnabled(false); 它成功了,图标和标题消失了,但我的物品仍然出现在右边。有没有办法完全删除标题和图标而不是隐藏它们。我在堆栈溢出中发现了一个类似的问题,但没有人回答 编辑 您的“菜单项”将永远不会显示为左对齐。它们将向右对齐。左边是
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
它成功了,图标和标题消失了,但我的物品仍然出现在右边。有没有办法完全删除标题和图标而不是隐藏它们。我在堆栈溢出中发现了一个类似的问题,但没有人回答
编辑
您的“菜单项”将永远不会显示为左对齐。它们将向右对齐。左边是标题和图标(当前已删除)以及导航(选项卡、列表等)。如果您有足够的操作栏项,它们将流向左侧,但始终从右侧开始。这不能通过Android SDK进行更改。您可以通过使用操作栏上的上下文菜单进行更改。查看Sherlock ABS演示,这里有一个活动:ActionModes,它显示了一个非常简单的示例,可能对您有用。您可以参考此代码,然后您可以获得解决方案…只需根据您的要求应用即可。
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
RelativeLayout relative = new RelativeLayout(getApplicationContext());
TextView tv1 = new TextView(this);
tv1.setText("Test1");
tv1.setTextColor(Color.GREEN);
tv1.setPadding(3,13,3, 12);
tv1.setId(1);
tv1.setOnClickListener(this);
TextView tv2 = new TextView(this);
tv2.setText("Test2");
tv2.setTextColor(Color.GREEN);
tv2.setPadding(3,13,3,12);
tv2.setId(2);
tv2.setOnClickListener(this);
TextView tv3 = new TextView(this);
tv3.setText("Test3");
tv3.setTextColor(Color.GREEN);
tv3.setPadding(3,13,3, 12);
tv3.setId(3);
tv3.setOnClickListener(this);
TextView tv4 = new TextView(this);
tv4.setText("Test3");
tv4.setTextColor(Color.GREEN);
tv4.setPadding(3,13,3, 12);
tv4.setId(4);
tv4.setOnClickListener(this);
LinearLayout ll = new LinearLayout(this);
ll.addView(tv1);
ll.addView(tv2);
ll.addView(tv3);
ll.addView(tv4);
relative.addView(ll);
actionBar.setCustomView(relative);
你说“成功了”,但你还是不开心。请考虑使用更多的单词,甚至图片,来解释你的问题。我能问一个相关的问题吗?我还尝试通过将显示设置为false来删除图标和标题。我膨胀自定义视图以替换图标和标题。但是,在自定义视图膨胀之前,我可以看到图标和标题。有什么想法吗?谢谢你的命令来隐藏图标和标题!非常有用,尽管你只是把它当作问题提出来。
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
RelativeLayout relative = new RelativeLayout(getApplicationContext());
TextView tv1 = new TextView(this);
tv1.setText("Test1");
tv1.setTextColor(Color.GREEN);
tv1.setPadding(3,13,3, 12);
tv1.setId(1);
tv1.setOnClickListener(this);
TextView tv2 = new TextView(this);
tv2.setText("Test2");
tv2.setTextColor(Color.GREEN);
tv2.setPadding(3,13,3,12);
tv2.setId(2);
tv2.setOnClickListener(this);
TextView tv3 = new TextView(this);
tv3.setText("Test3");
tv3.setTextColor(Color.GREEN);
tv3.setPadding(3,13,3, 12);
tv3.setId(3);
tv3.setOnClickListener(this);
TextView tv4 = new TextView(this);
tv4.setText("Test3");
tv4.setTextColor(Color.GREEN);
tv4.setPadding(3,13,3, 12);
tv4.setId(4);
tv4.setOnClickListener(this);
LinearLayout ll = new LinearLayout(this);
ll.addView(tv1);
ll.addView(tv2);
ll.addView(tv3);
ll.addView(tv4);
relative.addView(ll);
actionBar.setCustomView(relative);
getSupportActionBar().setIcon(android.R.color.transparent);