Android Question what should be the mask for...

LucaMs

Expert
Licensed 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:

LucaMs

Expert
Licensed User
Thanks, Erel, I know (one year here, if I did not know that, i can go fishing, lol)

I was trying to "convert" the values of gravity to HTML alignment (for all I know, it can be only center-right-left).

I think I have solved using Bit...

Thanks
 

RandomCoder

Well-Known Member
Licensed 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.
 
Top