可满足自定义偏好的标准填充
我创建了一个自定义首选项,但其填充看起来不像标准首选项的填充。有谁知道如何在不玩数字的情况下将它们相加?蓝色背景的图片上是一个没有预设填充的新首选项。
在多个设备上进行测试后发现,在不同设备上标准填充是不同的。如果手动设置填充,则会导致 UI 不一致。
I created a custom preference but its paddings do not look like paddings of a standard preference. Does anybody know a way how they can be added without playing with numbers? On the pic with the blue background is a new preference item without preset paddings.
After testing on several devices found out that on different devices standard paddings are different. It makes UI inconsistent if paddings were set up manually.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这看起来像是重复的,这个问题的答案也许可以帮助你。
自定义首选项,targetSdkVersion="11":缺少缩进?
This looks like a duplicate, the answer to this question might be able to help you.
Custom preference, targetSdkVersion="11": missing indent?
左侧的 Intent 是放置图标的地方。首选项布局有其自己的内容边距。如果我膨胀自己的布局,我必须自己定义空间和边距,布局不能部分继承。
然而,Preference 有一个“widgetLayout”布局,它占据了首选项控件右侧的剩余空间。该空间可以根据首选布局进行定制。
Intent on the left side is a place for an icon. Preference layout has its own margins for the content. If I inflate my own layout I have to define spaces and margins by my own, layout cannot be inherited partially.
However Preference has a "widgetLayout" layout which takes the rest of the space on the right side of the preference control. This space can be customized with preferred layout.
您通常希望保留默认视图元素,除非您有充分的理由更改它们。
3.x 的填充有所不同,因为它使用更大的屏幕。
您可以尝试为不同尺寸的屏幕指定不同的布局,看看这是否更适合你。
要记住的重要一点是:设备 UI 默认值比您的默认值更重要。这不是iOS。您正在将您的应用程序发送到野外,那里将会有各种疯狂的屏幕尺寸,您应该对应用程序进行这样的编程。
顺便说一句,另一个选项是使用显示独立像素指定尺寸,但用百分比和比率来描述事物几乎总是更好。
希望这有帮助!
You generally want to leave the default view elements alone unless you have a good reason to change them.
The padding for 3.x is somewhat different because it is using a larger screen.
You might try specifying different layouts for different size screens and see if that works better for you.
The important thing to remember is: the devices UI defaults are more important than your defaults. This is not iOS. You are sending your app out into the wild, where there are going to be all sorts of crazy screen sizes, and you should program the app as such.
On a side note, the other option is to use display-independent pixels to specify your sizes, but it's almost always better to describe things in percentages and ratios.
Hope this helps!