Levisvv Member Licensed User Longtime User Jul 29, 2014 #1 I am moving images around a layout, and need the top/left locations to be in dip format, how can I accomplish this when my code is as follows:? Code: Copy v.Left=(((col-1)*80)+7) v.Top=(((row-1)*96)+6) I cannot just add "dip" to the end of each row that gives an error?
I am moving images around a layout, and need the top/left locations to be in dip format, how can I accomplish this when my code is as follows:? Code: Copy v.Left=(((col-1)*80)+7) v.Top=(((row-1)*96)+6) I cannot just add "dip" to the end of each row that gives an error?
KMatle Expert Licensed User Longtime User Jul 29, 2014 #2 Haters gonna hate... I like to add views on my own and I don't "like" to use dip. Why? Because there is a mix between absolute coordinates (with some%x and some%y) and relative "dip" (here I don't know how large the view really is - except I check the absolute coordinates - and then I'm back to x+y). Even when you use texts in a label/edittext. You always have to calculate the size. Take a look here: http://www.b4x.com/android/forum/threads/supporting-multiple-screens-tips-and-best-practices.17647/ Upvote 0
Haters gonna hate... I like to add views on my own and I don't "like" to use dip. Why? Because there is a mix between absolute coordinates (with some%x and some%y) and relative "dip" (here I don't know how large the view really is - except I check the absolute coordinates - and then I'm back to x+y). Even when you use texts in a label/edittext. You always have to calculate the size. Take a look here: http://www.b4x.com/android/forum/threads/supporting-multiple-screens-tips-and-best-practices.17647/
Erel B4X founder Staff member Licensed User Longtime User Jul 29, 2014 #3 You can use: Code: Copy v.Left = DipToCurrent(((col-1)*80)+7) Upvote 0
klaus Expert Licensed User Longtime User Jul 29, 2014 #4 This works too: Code: Copy v.Left = (col - 1) * 80dip + 7dip Upvote 0