Xamarin.Android CustomActionBar(工具栏)布局问题

时间:2017-03-31 15:08:23

标签: android xamarin xamarin.android

我在工具栏中有一个关于xamarin.android的非常有趣的问题。 我创建导航抽屉切换没有问题。

在此之后我需要弹出菜单,以便在活动的'OnCreateOptionsMenu'中弹出弹出菜单。

然后我看到了那个问题

There is an image

活动

public byte[] convertStreamToByteArray(InputStream is) throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  byte[] buff = new byte[1024];
  int i = 0;
  while ((i = is.read(buff, 0, buff.length)) > 0) {
    baos.write(buff, 0, i);
  }
  return baos.toByteArray();
}

AXML

    mToolbar = FindViewById<SupportToolbar>(Resource.Id.toolbar);
    mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
        SetSupportActionBar(mToolbar);
        SupportActionBar.SetTitle(Resource.String.ApplicationName);

        mDrawerToggle = new MyActionBarDrawerToggleHelper(
            this,                           //Host Activity
            mDrawerLayout,                  //DrawerLayout
            Resource.String.openDrawer,     //Opened Message
            Resource.String.closeDrawer     //Closed Message
        );

        mDrawerLayout.AddDrawerListener(mDrawerToggle);
        SupportActionBar.SetDisplayHomeAsUpEnabled(true);
        SupportActionBar.SetDisplayShowTitleEnabled(false);
        SupportActionBar.SetHomeButtonEnabled(true);
        mDrawerToggle.SyncState();

1 个答案:

答案 0 :(得分:1)

尝试改为设置这些参数:

android:layout_height="?actionBarSize"
android:minHeight="?attr/actionBarSize"