标签即将上述行动吧充气自定义布局时自定义、布局、上述、行动

2023-09-12 21:47:59 作者:颓废

我想在这里对所有#1的其他答案,但它不工作提到了一切。这是我的code。

 动作条= getActionBar();
actionBar.setBackgroundDrawable(新ColorDrawable(Color.parseColor(#FFFFFF)));
actionBar.setDisplayShowHomeEnabled(真正的);
actionBar.setDisplayShowCustomEnabled(真正的);
actionBar.setCustomView(R.layout.actionbar_layout);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setLogo(空);
actionBar.setDisplayShowTitleEnabled(假);
查看homeIcon = findViewById(android.R.id.home);
((查看)homeIcon.getParent())setVisibility(View.GONE)。
 

解决方案

该选项卡显示在上面,当你隐藏的主页项目。这是一个有点反直觉的,但同时也提出了一些设计感。他们基本上是轻推,你要使用标签作为标题的部分和使用操作栏下方他们为这些节内的行动。

您需要 setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME)使标签再次回落。它可能会需要一个非空的标志太(你可以做一个1px的透明之一-nodpi让它消失)

edge浏览器如何自定义背景颜色 edge浏览器自定义背景颜色的方法 河东软件园

I tried everything mentioned here on all Stackoverflow's other answers but its not working out. Here is my code.

actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffffff")));
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.actionbar_layout);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setLogo(null);
actionBar.setDisplayShowTitleEnabled(false);
View homeIcon = findViewById(android.R.id.home);
((View) homeIcon.getParent()).setVisibility(View.GONE);

解决方案

The tabs show on top when you hide the Home item. It is a bit counter intuitive but it also makes some design sense. They're essentially nudging you to use the tabs as titles for the sections and use the action bar below them for actions inside those sections.

You need setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME) to bring the tabs down again. It will probably need a non-null logo too (you can make a 1px transparent one in -nodpi to make it disappear)