Android Question Galaxy Tab 3 10.1 / 4.2.2 / Dips?

Osi

Member
Licensed User
Longtime User
I have been looking for DIP information for the DrawText method against the ImageView. I am currently designing and debugging on the device itself.

DipToCurrent doesn't seem to apply for that device. Even IntToDIP methods do not work either. Is this device just special, or unique in the Android world? Basically, if you place something as simple as:
B4X:
c.DrawText("Card #" & tag, DipToCurrent(10), DipToCurrent(10), Typeface.DEFAULT, 24, Colors.White, "LEFT")
All you see is the bottom third of the text in the imageview. You get the same results with the following lines of code, no matter what you do.
B4X:
c.DrawText("Card #" & tag, 0, 0, Typeface.DEFAULT, 24, Colors.White, "LEFT")
B4X:
c.DrawText("Card #" & tag, 0dip, 0dip, Typeface.DEFAULT, 24, Colors.White, "LEFT")

It is looking more and more that this particular tablet is just ... "unique". Or perhaps not compatible with Basic4Android?
 

klaus

Expert
Licensed User
Longtime User
The problem are the x and y values in your code.
The y coordinate of the reference point is the base line of the text not the top of the text.
In your first code example you set the y reference to 10dip for a text size of 24 which is by far too low.
Try the code below:
B4X:
c.DrawText("Card #" & tag, 10dip, 30dip, Typeface.DEFAULT, 24, Colors.White, "LEFT")
 
Upvote 0

Osi

Member
Licensed User
Longtime User
Thank you for the replies. Then I am thoroughly confused.

I am trying to draw some text via canvas onto an ImageView at the 0,0 location, or even 5,5 on the image. It sounds like the x and y parameters are not really for the left and top position? By baseline you mean the bottom of the text?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
542px-Typography_Line_Terms.svg.png


The y coordinate is the baseline.
The position in the x coordinate depends on the Gravity.
 
Upvote 0

Osi

Member
Licensed User
Longtime User
Thank you for the explanation :) That is definitely a difference between other languages. Usually, X = left, and Y = top. I'm going to have to go through other methods to see if the same difference is there.

Thanks again.
 
Upvote 0
Top