Linked Questions

Popular Questions

How size units in Android are applied?

Asked by At

When adding a view in an axml file, it is possible to simply specify the size and the units of the view's attribute, for example:

<TextView
    android:TextSize = "10sp"
    android:layout_marginTop = "10dp" />

But when applying a size programmatically, what are the units applied for the size sp? dp? px?

TextView tv = new TextView();
tv.TextSize = 10;

Also, how can I convert units?

Related Questions