I'd use the analogue way you're setting your height and width: via getLayoutParams()
. If you want to set the params dynamically, I wouldn't use pixels directly but the dp
unit, using TypedValue.COMPLEX_UNIT_DIP
.
Regarding to synchronization, in that example I'd definitely use asynchronous mechanisms, such as CountDownLatch
or Semaphore
mechanisms. It's quite more secure this way than using temporary timers. You may want to check the CountDownLatch(1)
example in the reference page for that purpose.