Android 制作一个带有菜单图标的工具栏,如amazon应用程序
我正在尝试制作一个带有菜单图标的工具栏,比如亚马逊应用程序。但工具栏菜单图标设置不正确。实际上,所有菜单图标都设置为从左到右。我需要回图标和导航图标设置在右侧,应用程序的标志设置在中心和其他图标设置在左侧 菜单代码Android 制作一个带有菜单图标的工具栏,如amazon应用程序,android,android-layout,android-studio,android-toolbar,android-design-library,Android,Android Layout,Android Studio,Android Toolbar,Android Design Library,我正在尝试制作一个带有菜单图标的工具栏,比如亚马逊应用程序。但工具栏菜单图标设置不正确。实际上,所有菜单图标都设置为从左到右。我需要回图标和导航图标设置在右侧,应用程序的标志设置在中心和其他图标设置在左侧 菜单代码 <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schema
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<item
android:id="@+id/action_bookmark"
android:icon="@drawable/ic_bookmark_white_24dp"
android:orderInCategory="100"
android:title="@string/action_bookmark"
app:showAsAction="always" />
<item
android:id="@+id/action_back"
android:icon="@drawable/ic_keyboard_arrow_left_white_24dp"
android:orderInCategory="101"
android:title="@string/action_back"
app:showAsAction="always" />
<item
android:id="@+id/texttite"
android:icon="@mipmap/ic_launcher"
android:orderInCategory="102"
android:title="@string/action_forward"
android:titleCondensed="hello........"
app:showAsAction="always" />
<item
android:id="@+id/action_forward"
android:icon="@drawable/ic_keyboard_arrow_right_white_24dp"
android:orderInCategory="103"
android:title="@string/action_forward"
app:showAsAction="always" />
<item
android:id="@+id/action_bookmark1"
android:icon="@drawable/ic_bookmark_white_24dp"
android:orderInCategory="104"
android:title="@string/action_bookmark"
app:showAsAction="always" />
</menu>
我需要这种类型的工具栏。我尝试过,但没有成功。请帮帮我
这是自定义工具栏代码
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:padding="0px"
android:layout_margin="0px"
app:popupTheme="@style/AppTheme.PopupOverlay" >
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
您可以根据需要自定义工具栏布局,就像其他布局一样。请在下面找到仅使用按钮的示例布局
您必须将视图添加到工具栏(设计工具栏)。您不能使用菜单膨胀来获得类似亚马逊应用程序的工具栏。如何使用它,请举例说明。您为什么不在工具栏中膨胀自定义布局或使用自定义布局来代替工具栏先生,请举例说明。谢谢先生的回答。但我用的是菜单项,不是按钮。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorBlack">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="<" />
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="=" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom"
android:textColor="@color/backgroundColorGenericWhite"
android:textSize="22sp" />
</LinearLayout>
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="=" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</LinearLayout>