We all know that a TextView has an attribute "textSize", whose unit varies from "dp" to "sp".
But one day when I am searching a question "Set ImageView width and height programmatically", I find the highest voted answer wrote: image_view.getLayoutParams().height = 20;
Actually I want to programmingly set an ImageView's height as tall as a TextView, but the textSize of the TextView is 20dp, and the height of the ImageView is an int, 20.
So what is the relation between "dp" and "int" ? How can I convert one to another ?