蜂窝状操作栏和边距
我尝试在操作栏上使用不同的“homeAsUpIndicator”图形,但我遇到了屏幕边缘和图形的一些边距问题。
在项目的 styles.xml 中使用值为 @drawable/my_graphic 的“android:homeAsUpIndicator”属性,我成功地将指示器更改为自定义图形。该图形在设计时考虑了 0dp 左边距 - 因为图形的左边缘应该一直到屏幕的左边缘。相反,我在图像的顶部和左侧都有 6 像素的边距。
我尝试在 styles.xml 中设置边距和填充,但要么不起作用,要么我将其应用到了错误的资源。另外,我尝试将操作栏背景设置为 9 块图形,并让标准指示器图形(Honeycomb 3.1 中的“<”)浮动在其顶部...但这也不起作用,因为它只是将背景固定像素右侧的指示图形。它仅覆盖 9 块中被识别为拉伸像素的像素。
有没有办法从操作栏中删除 6 像素填充/边距,以便指示器图形与屏幕左侧齐平?任何示例或线索将不胜感激!
谢谢
I'm attempting to use a different "homeAsUpIndicator" graphic on the action bar, and I'm running into some margin issues with the edge of the screen and the graphic.
Using the "android:homeAsUpIndicator" attribute with a value of @drawable/my_graphic in the styles.xml for the project, I've managed to change the indicator to a custom graphic. That graphic has been designed with a 0dp left margin in mind - as in the left edge of the graphic should go all the way to the left edge of the screen. Instead, I'm getting a 6 pixel margin on both the top and the left side the image.
I've tried setting the margins and padding in my styles.xml, but either that doesn't work or I've applied it to the wrong resource. Also, I tried setting the actionbar background to a 9-patch graphic and let the standard indicator graphic (the "<" in Honeycomb 3.1) float on top of it...that didn't work either, as it just pushed the indicator graphic to the right of the fixed pixels of the background. It only overlayed the pixels that were identified as the stretch pixels in the 9-patch.
Is there a way to remove the 6-pixel padding/margin from the actionbar so the indicator graphic is flush with the left side of the screen? Any examples or leads would be greatly appreciated!
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否提供了针对不同屏幕尺寸/分辨率/密度的绘图?
尽管它们应该自动调整大小。
操作栏的图标设计请参见此处:
http://developer.android.com/guide/practices/ui_guidelines/icon_design_action_bar。 您还可以检查 sdk文件
夹中使用的标准图标,并根据这些图标进行调整:
路径为:
ANDROID_SDK/platforms/android-XX/data/res/drawable-XXX
https://stackoverflow.com/questions/8179653/where-can- i-find-standarts-icons-for-actionbar
否则也请在此处检查:
如何删除 ActionBar 上应用程序图标和屏幕边缘之间的边距?
您也可以使用自定义操作栏:
不带填充的自定义标题栏 (Android)
Have you provided drawables for different screen sizes / resolutions / densities?
Though they should resize automatically.
See here for icon design of action bar :
http://developer.android.com/guide/practices/ui_guidelines/icon_design_action_bar.html
Also you can check the standard icons being used in your sdk folder and adapt yours to those:
the path is:
ANDROID_SDK/platforms/android-XX/data/res/drawable-XXX
https://stackoverflow.com/questions/8179653/where-can-i-find-standarts-icons-for-actionbar
Otherwise check also here:
How to remove the margin between the app icon and the edge of the screen on the ActionBar?
Also you could use a custom action bar:
Custom title bar without padding (Android)