Android 操作栏图标大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11244918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:30:12  来源:igfitidea点击:

Action Bar icon size

androidiconsandroid-actionbaractionbarsherlock

提问by Giorgi

According to Action Bar Iconsaction bar icon for the mdpi screen should be 24 x 24 px but the icons in Action Bar Icon Packfor mdpi are 32 x 32 px. The sizes do not match for other screen sizes neither. So which one is correct and what dimensions should the action bar icon have?

根据操作栏图标的屏幕MDPI动作栏图标应为24×24像素,但在图标的操作栏图标包适用于mdpi是32×32像素。尺寸与其他屏幕尺寸也不匹配。那么哪个是正确的,操作栏图标应该有什么尺寸?

采纳答案by Alex Curran

UPDATE: this answer is no longer valid, see the below answer for more up-to-date guidelines.

更新:此答案不再有效,有关更多最新指南,请参阅以下答案。

I believe they have to be 32x32dp, but the actual image itself should be 24dpx24dp centred. The Android design website has the correct guidelines.

我相信它们必须是 32x32dp,但实际图像本身应该以 24dpx24dp 为中心。Android 设计网站有正确的指南

I've submitted a bug reportabout this but have yet to hear anything...

我已经提交了关于此的错误报告,但还没有听到任何消息......

回答by wangqi060934

-------update 2015.10.17--------

-------更新2015.10.17--------

The new google design gidelinesays:"System icons are displayed at 24dp","Icon content is limited to the 20 x 20dp live area, with 4px of trim around the perimeter".Like:

新的 google design gideline说:“系统图标以 24dp 显示”,“图标内容仅限于 20 x 20dp 的活动区域,周边有 4px 的修剪”。如:

enter image description here------old-------

在此处输入图片说明- - - 老的 - - - -

Full asset, 32x32 dp; Optical square, 24x24 dp

完整资源,32x32 dp;光学方形,24x24 dp

enter image description here

在此处输入图片说明

回答by OneWorld

I've conducted more testing with AppCompat ActionBar. I found out, that the ActionBar takes care for itself to enforce the minimum 48dp touch target size. I also found out, that the AppCompat ActionBar still expects action bar icons with a 32dp square size.

我已经使用 AppCompat ActionBar 进行了更多测试。我发现,ActionBar 会自行执行最小 48dp 触摸目标尺寸。我还发现,AppCompat ActionBar 仍然需要 32dp 正方形大小的操作栏图标。

Even with Material design, icons still have to follow rule "Full asset: 32x32 dp; Optical square: 24x24 dp" to have the correct size along with other icons in the action baras this figure (from wangqi060934's anwer) shows:

即使使用 Material design,图标仍然必须遵循“Full asset: 32x32 dp; Optical square: 24x24 dp”的规则才能与操作栏中的其他图标一起具有正确的大小,如下图(来自 wangqi060934 的答案)所示:

enter image description here

在此处输入图片说明

My previous assumption (see figures below) that the full asset size expanded from 32dp to 48dp is not correct.The 48dp are talking about the touch area. The confusion was caused by the revised Material Icon Spec documentwhich is linked in the much older ActionBar document.

我之前的假设(见下图)认为完整资产大小从 32dp 扩展到 48dp 是不正确的。48dp 正在谈论触摸区域。混乱是由修订的Material Icon Spec 文档引起的,该文档链接在更旧的ActionBar 文档中

enter image description here

在此处输入图片说明

from https://www.google.com/design/spec/style/icons.html#icons-system-icons

来自https://www.google.com/design/spec/style/icons.html#icons-system-icons

enter image description here

在此处输入图片说明

from http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylines-sizing-by-increments

来自http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylines-sizing-by-increments

回答by CarLoOSX

Use Android Studio Image Asset

使用 Android Studio 图像资源

Go to:

去:

  1. Project>res --> right click
  2. new> image asset --> Icon type: Action Bar and Tab Icons
  3. next>Finish.
  1. 项目>资源->右键单击
  2. 新建> 图像资产 --> 图标类型:操作栏和选项卡图标
  3. 下一个>完成。

Now you will have your icon in the correct resolutions.

现在您将拥有正确分辨率的图标。

回答by Radoslav

The finished action bar icon dimensions as shown in the link below should be. https://developer.android.com/guide/practices/ui_guidelines/icon_design_action_bar.html

完成后的操作栏图标尺寸应如下面的链接所示。 https://developer.android.com/guide/practices/ui_guidelines/icon_design_action_bar.html

Low density screen

低密度屏

ldpi (120 dpi) --> 18 x 18 px

Medium density screen

中密度屏

mdpi (160 dpi) --> 24 x 24 px

High density screen

高密度屏

hdpi (240 dpi) --> 36 x 36 px

Extra-high density screen

超高密度屏

xhdpi (320 dpi) --> 48 x 48 px  

XX-high density screen

XX-高密度屏

xxhdpi (480 dpi) --> 72 x 72 px

XXX-high density screen

XXX-高密度屏

xxxhdpi (640 dpi) --> 96 x 96 px