Android Question Perfect rectangle?

wimpie3

Well-Known Member
Licensed User
Longtime User
When I draw a rectangle on the Activity having width = activity.width and height = activity.width (which means the rectangle has the same width as height) the resulting rectangle is NOT a perfect rectangle. It looks higher than its width. What am I missing here? A pixel density problem? How can I draw a perfect rectangle?
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Exactly what I'm saying: a square with 100dip x 100dip looks like a rectangle on my mobile!
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
The exact physical pixels per inch of the screen in the X dimension could be not the same as in the Y dimension. "dip" are units independ.

Try:

B4X:
Sub Activity_Create (FirstTime As Boolean)
   Dim r As Reflector
   r.Target = r.GetContext
   r.Target = r.RunMethod("getResources")
   r.Target = r.RunMethod("getDisplayMetrics")
   Log(r.GetField("xdpi"))
   Log(r.GetField("ydpi"))
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…