我想风格我的应用程序的动作栏。由于我需要定制更多,我用ToolBar替换了实际的ActionBar。我想要设计ActionBar,如下图所示image1。自定义与不同背景颜色的动作栏 - Android
下面是我使用的自定义工具栏的代码。
custom_actionbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.Toolbar
android:id="@+id/actionbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</RelativeLayout
activity_toolbar.java
// Custom actionbar starts here
Toolbar action = (Toolbar) findViewById(R.id.actionbar);
action.inflateMenu(R.menu.menu_scrollable_tabs);
action.setNavigationIcon(R.drawable.ct_drawer);
我正在操作栏像下面图像2,
1)这个问题我我是cing是我没有得到像客户要求的导航图标和菜单图标。
2)如何使用工具栏来实现这一点。请提供是否有任何其他替代方式来实现这一点在Android中。
请帮忙。
好,如何有导航图标和菜单图标类似于像我的第一个图像(即此搜索)。我想要导航图标的背景颜色,菜单图标应该填充工具栏的顶部和底部区域。这个怎么做。 – user2681579
您需要创建这些图标并将它们添加为菜单项,如果您正在使用导航抽屉,则可以将其图标用于最左侧的图标 –