如何更改android顶部工具栏菜单项图标大小
如何更改android工具栏中菜单项的大小?目前菜单的尺寸很小,我想增加尺寸。如果有人知道,请帮我找到解决办法 app_bar.xml如何更改android顶部工具栏菜单项图标大小,android,android-toolbar,Android,Android Toolbar,如何更改android工具栏中菜单项的大小?目前菜单的尺寸很小,我想增加尺寸。如果有人知道,请帮我找到解决办法 app_bar.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_p
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor"
android:minHeight="?attr/actionBarSize"
android:paddingTop="@dimen/app_bar_top_padding"
android:theme="@style/ToolBarStyle"/>
我也遇到了这个问题,唯一的解决办法就是使用更小的图像。这里的图标()的大小为24dp,非常适合我的工具栏 您可以设计自定义布局并将其添加为actionlayout。另外,请确保不要在menu.xml文件中添加任何图标
<item android:id="@+id/homes"
android:title="homes"
app:actionLayout="@layout/your_custom_layout"
app:showAsAction="always"/>
然后在自定义布局中指定最小高度。我建议您阅读此博客了解自定义工具栏
您可以使用该菜单xml文件中的“app:actionLayout”来指定另一个xml文件(您将在其中创建自定义工具栏图标),而不是将可绘制图标添加到菜单xml文件中。只需将矢量图像的大小(右侧)从默认的24x24增加到不同的大小,但在达到一定大小后,它将不会放大。如果将其放在自定义工具栏中膨胀的视图(左侧为橙色背景)旁边(如图所示),其大小可能会显得很奇怪,唯一的解决方法是将矢量作为背景在工具栏中膨胀另一个视图。我尝试过该教程,但没有任何选项可以改变菜单的大小icons@PrinsPrem我对工具栏内的图标大小也有同样的问题。想知道你能不能找到解决这个问题的办法?提前谢谢。有什么解决办法吗?我也遇到了这个问题
<?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/homes"
android:title="homes"
android:icon="@drawable/ic_action_home1"
app:showAsAction="always"/>
<item android:id="@+id/profilepreview"
android:title="ProfilePreview"
android:icon="@drawable/profile"
app:showAsAction="always"/>
<item android:id="@+id/findPeople"
android:title="findPeople"
android:icon="@drawable/ic_action_search1"
app:showAsAction="always"/>
<item android:id="@+id/log"
android:title="log"
android:icon="@drawable/ic_action_logout1"
app:showAsAction="always"/>
</menu>
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_option, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.profilepreview:
startActivity(new Intent(this, ProfilePreview.class));
return true;
case R.id.homes:
mFragment = new HomeFragment();
break;
case R.id.findPeople:
mFragment = new FindFriendsFragment();
break;
case R.id.log:
M.logOut(this);
mIntent = new Intent(this, LoginActivity.class);
finish();
}
if (mFragment != null && mIntent == null) {
mFragmentManager = getFragmentManager();
mFragmentManager.beginTransaction()
.replace(R.id.frameContainer, mFragment).commit();
} else {
startActivity(mIntent);
mIntent = null;
}return super.onOptionsItemSelected(item);
}
<item android:id="@+id/homes"
android:title="homes"
app:actionLayout="@layout/your_custom_layout"
app:showAsAction="always"/>