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>
問題は、オプションメニューにはいくつかの余白(パディング?)があります - 上下です。あなたはこのスクリーンショットを見てとることができます。
私は(最初が最も重要となっている)の3つの質問があります。私は、これらの余白を取り除くにはどうすればよい
- を?
android:icon
メニュー項目には何の効果もありません。どうすればアイコンを置くことができますか?それができない場合:- どのように3つのドットの色を変更するには?