java工具栏中的溢出菜单图标
我正在使用appCompat v7:24.2.1,我刚刚学习了一个关于材料的简单教程。我只是不知道如何在创建的工具栏的右侧中获得溢出菜单
自定义应用程序工具栏
<安卓.support.v7.widget.Toolbar xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:background="#F44336"
>
梅因。xml
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:id="@+id/activity_main"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
tools:context="com.example.ud.materialdesigntest.MainActivity">
<!-- Was inside the RelativeLayout Tag
安卓:paddingBottom="@dimen/activity_vertical_margin"
安卓:paddingLeft="@dimen/activity_horizontal_margin"
安卓:paddingRight="@dimen/activity_horizontal_margin"
安卓:paddingTop="@dimen/activity_vertical_margin"
-->
<include
安卓:id="@+id/app_bar"
layout="@layout/app_bar" />
<TextView
安卓:layout_below="@+id/app_bar"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="Hello World"
安卓:id="@+id/textViewHelloWorld" />
梅因。爪哇
public class MainActivity extends AppCompatActivity {
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar)findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
}
}
# 1 楼答案
尝试使用以下代码:
要更改溢出图标,可以定义如下样式:
无论如何,更改标准图标(如溢出菜单)可能不是一个好主意
如果要更改图标的颜色,可以使用: