BA4 error or normal ?

Hubert Brandel

Active Member
Licensed User
Longtime User
Hi,

I use labels to display Values.
But some users can click on it and start an editor windows.
I just take the labels size and position and create a editView a little bit bigger,
with this code it works fine on my Samsung Galaxy S and some other devices:

B4X:
Sub EditFeldopen( nLeft As Int, nTop As Int, nWidth As Int )
   Dim nHeight As Int : nHeight = 60
   ...
   ' editview have margins
   nLeft = nLeft-5
   nTop  = nTop-5
   nWidth = nWidth+10
   'EditFeld.SetLayout( nLeft , nTop, nWidth, nHeight )
   EditFeld.Left = nLeft
   EditFeld.Top = nTop
   EditFeld.Width = nWidth
'   EditFeld.Height = nHeight ' defined in designer, will not change

then I found a method to change the size with one line ...
B4X:
Sub EditFeldopen( nLeft As Int, nTop As Int, nWidth As Int )
   Dim nHeight As Int : nHeight = 60
   ...
   ' editview have margins
   nLeft = nLeft-5
   nTop  = nTop-5
   nWidth = nWidth+10
   ' shorter ...
   EditFeld.SetLayout( nLeft , nTop, nWidth, nHeight )

It works on my Samsung, but on a X2 Tablet with the same size and dpi the editview was bigger than it should be ?

Does this changes more than just the sizes ?
 

stevel05

Expert
Licensed User
Longtime User
You can change the padding (Margins) in the edit text using the reflection library if it helps with alignment:


B4X:
Dim refl AS Reflector
refl.Target=EditFeld
refl.RunMethod4("setPadding", Array As Object(Left, Top, Right, Bottom), _
   Array As String("java.lang.int", "java.lang.int", "java.lang.int","java.lang.int"))

Where Left,Top,Right and Bottom are integer variables.
 
Upvote 0
Top