German Top und Left richtig darstellen

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hallo,

einer von euch ne Idee, wie ich auf das Top die 6 addieren kann?

so geht es leider nicht.
B4X:
Title1.Gravity = (Gravity.TOP + 6) + Gravity.LEFT

gruß
sinan
 

klaus

Expert
Licensed User
Longtime User
So geht das nicht.
Gravity.Top, Gavity.Left usw. sind Codewerte und nicht Pixels.
Wenn Ich richtig verstanden habe willst Du die 'Paddingwerte' (Ränder) ändern.
Das kann man so machen, schreiben und lesen:
B4X:
'Sets the padding of a view
Sub SetPadding(v As View, Left As Int, Top As Int, Right As Int, Bottom As Int)
    Dim refl As Reflector
    
    refl.Target = v
    Dim args(4) As Object
    Dim types(4) As String
    args(0) = Left
    args(1) = Top
    args(2) = Right
    args(3) = Bottom
    types(0) = "java.lang.int"
    types(1) = "java.lang.int"
    types(2) = "java.lang.int"
    types(3) = "java.lang.int"
    refl.RunMethod4("setPadding", args, types)
End Sub

'Gets the Left padding of the given view
Sub GetPaddingLeft(v As View) As Int
    Dim refl As Reflector
    
    refl.Target = v
    Return refl.RunMethod("getPaddingLeft")
End Sub

'Gets the Top padding of the given view
Sub GetPaddingTop(v As View) As Int
    Dim refl As Reflector
    
    refl.Target = v
    Return refl.RunMethod("getPaddingTop")
End Sub

'Gets the Right padding of the given view
Sub GetPaddingRight(v As View) As Int
    Dim refl As Reflector
    
    refl.Target = v
    Return refl.RunMethod("getPaddingRight")
End Sub

'Gets the Bottom padding of the given view
Sub GetPaddingBottom(v As View) As Int
    Dim refl As Reflector
    
    refl.Target = v
    Return refl.RunMethod("getPaddingBottom")
End Sub
Beste Grüsse.
 
Top