Android Question what should be the mask for...

LucaMs

Expert
Licensed User
Longtime User
Gravity could contain:
Gravity.CENTER
Gravity.CENTER_HORIZONTAL
Gravity.CENTER_VERTICAL

Dim Mask As Int = ? <------

Center = Bit.And(Label1.Gravity, Mask)
If Center = Gravity.CENTER...

(so I did not have to think of the English translation :))



[P.S. little help... for you :D

B4X:
Log(Gravity.BOTTOM)           '  80
Log(Gravity.CENTER)           '  17
Log(Gravity.CENTER_HORIZONTAL)'   1
Log(Gravity.CENTER_VERTICAL)  '  16
Log(Gravity.FILL)             ' 119
Log(Gravity.LEFT)             '   3
Log(Gravity.NO_GRAVITY)       '   0
Log(Gravity.RIGHT)            '   5
Log(Gravity.TOP)              '  48


Or MUST I use:
B4X:
Center = Bit.AND(Label1.Gravity, Gravity.Center)
Center = Bit.OR(Center, Bit.AND(Label1.Gravity, Gravity.CENTER_HORIZONTAL))
Center = Bit.OR(Center, Bit.AND(Label1.Gravity, Gravity.CENTER_VERTICAL))
If Center = Gravity.Center Then
    Log("Center")
End If
 
Last edited:

RandomCoder

Well-Known Member
Licensed User
Longtime User
I'm not sure that I have understood correctly what you want to achieve, but could you instead use a Map?
The 'key' can be the different label gravity's and the 'value' can be whatever gravity you what it converted to.
 
Upvote 0
Top