Ich verwende eine benutzerdefinierte Symbolleiste, die auf diese Weise aufgebaut ist:Android Optionsmenü oberen und unteren Rand
<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>
Es ist Nutzung:
<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>
Ich versuche Optionen-Menü hinzufügen, um meine Anwendung, so zu tun, um, dass ich diese Methode, um meine Aktivität hinzugefügt:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
((Toolbar)findViewById(R.id.toolbar)).inflateMenu(R.menu.main_menu);
return true;
}
Und mein main_menu
Layout:
Das Problem ist, dass das Optionsmenü einige Ränder (Paddings?) - oben und unten hat. Sie können an diesem Screenshot einen Blick:
Ich habe drei Fragen (von denen die ersten das wichtigste ist):
- Wie kann ich diese Ränder loszuwerden?
android:icon
auf Menüeintrag hat keinen Effekt, also wie lege ich ein Symbol dort? Wenn das nicht möglich ist:- Wie ändert man die Farbe dieser drei Punkte?