我有导航抽屉,为了在操作栏上显示它,我制作了自定义工具栏视图并将其设置为操作栏。现在我有箭头图标,我不能改变。操作栏(工具栏)图标
这是我基本活动的一部分,我想这些方法,没有什么变化:MainActivity在那里我有工具栏的XML的
protected void onCreateDrawer()
{
// R.id.drawer_layout should be in every activity with exactly the same id.
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
drawerToggle = new ActionBarDrawerToggle((Activity) this, drawerLayout, R.drawable.ic_drawer, 0, 0)
{
public void onDrawerClosed(View view)
{
getSupportActionBar().setTitle(R.string.app_name);
}
public void onDrawerOpened(View drawerView)
{
getSupportActionBar().setTitle("Aaaaaaaaaaa");
}
};
drawerLayout.setDrawerListener(drawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setLogo(R.drawable.ic_drawer);
getSupportActionBar().setDisplayShowTitleEnabled(true);
组成部分,活动的所有内容框架布局设置:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<!-- The main content view -->
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/tool_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
Navigation Drawer over Action bar很好用,但是,我无法更改工具栏上的任何图标。
我在工具栏上设置图标,然后添加它就像操作栏,它很好,但没办法,我可以设置标题或其他与ActionBar /工具栏。
澄清你的问题 –
添加这些行'getSupportActionBar()setDisplayHomeAsUpEnabled(真)。 getSupportActionBar()。setHomeButtonEnabled(true);' –
我已经有这些行...请参阅代码。 我的问题是,我不能在操作栏/工具栏上设置任何东西。标题等... – Sasaman