如何读取按位运算符 OR (|) 的结果?
我想要确认 Android XML 文件中的按位运算符。例如这一行
android:layout_gravity="center_horizontal|bottom"
我应该如何阅读它?是从Java继承的规则还是Android有自己的按位运算符解释?
是否支持所有位运算符?如果是,您能给我展示其他运营商的示例吗(链接也可以)?
谢谢
I would like the confirmation on bitwise operators inside Android XML files. For example this line
android:layout_gravity="center_horizontal|bottom"
How should I read it? Are the rules inherited from Java or Android does its own interpretation of bitwise operators?
Are all bitwise operators supported? If yes, could you show me the example of other operators (link is fine as well)?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
central_horizontal、bottom 是整数,因此您可以使用此结构
central_horizontal, bottom are integers so you can use this construction
android_layout_gravity
的值由 Android 代码解析。如此处所述,此处唯一可识别的运算符是|
。我不认为将|
解释为按位 OR 运算符是规范的一部分。 (例如,center_horizontal
是 0x05,right
是 0x01;它们的按位 OR 将只是 0x05。)The value of
android_layout_gravity
is parsed by Android code. As documented here, the only recognized operator here is|
. I don't believe that interpreting|
as bitwise OR operator is part of the spec. (For instance,center_horizontal
is 0x05 andright
is 0x01; their bitwise OR would just be 0x05.)