I would like to know how it is possible to move a TextView with float values ? We cannot divide a pixel so how is it possible to write something like
TextView t = (TextView)findViewById(R.id.textview);
t.setX(1.5f);
t.setY(1.5f);
? I just don't understand why we can put a float value here.
Thank you
The preferred geometric unit of measure in Android is dp (Density-independant pixels). The amount of pixels in a dp depends on the screen size of the device used. Using dp instead of actual pixels makes it easier to develop device independant apps.
Therefore, there is not really a reason why you can't have floating point dp!
However, View.setX() is used to set pixels (px), not dp. The only reason I can think of that this takes a floating value is to make convertion between dp and px easier.
However, they are not consistent in this. For example, the method View.setBottom() does take an int instead of a float.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With