我想風格我的應用程序的動作欄。由於我需要定製更多,我用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
您需要創建這些圖標並將它們添加爲菜單項,如果您正在使用導航抽屜,則可以將其圖標用於最左側的圖標 –