0
我使用的是建立這樣一個自定義工具欄:的Android選項菜單的頂部和底部邊緣
<android.support.v7.widget.Toolbar
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:paddingLeft="0dp"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetEnd="0dp"
android:contentInsetRight="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/deepDarkVioletToolbar">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/defaultMargin"
android:layout_marginTop="16dp"
android:background="@drawable/logo" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
它的使用:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".views.activities.MainActivity">
<include
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
layout="@layout/default_toolbar" />
<!-- other views go here -->
</RelativeLayout>
我想選擇菜單添加到我的應用程序,所以爲了做到這一點我加入這個方法我的活動:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
((Toolbar)findViewById(R.id.toolbar)).inflateMenu(R.menu.main_menu);
return true;
}
而且我main_menu
佈局:
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/appMenu"
android:title="menu"
android:visible="true"
app:showAsAction="always"
app:actionViewClass="android.Widget.ImageButton"
android:icon="@drawable/menu_bg"
android:enabled="true"
android:checkable="false">
<item android:title="Your orders" />
<item android:title="Log out" />
</item>
</menu>
問題是選項菜單有一些邊距(填充?) - 頂部和底部。您可以在這張截圖看看:
我有三個問題(其中第一個是最重要的):
- 如何擺脫那些利潤率?
android:icon
對菜單項沒有任何影響,所以如何在那裏放置一個圖標?如果這是不可能的,那麼:- 如何改變這三個點的顏色?