Muz
Muz

Reputation: 5980

"Pixel" terminology in Android documentation

I know that dip is standard for determining sizes on android. So when the documentation says "pixels" (for example in the Position segment of this page), does it literally mean pixels or density independent pixels?

Upvotes: 0

Views: 60

Answers (2)

Diego Torres Milano
Diego Torres Milano

Reputation: 69396

All those pixels units are not scaled.

Upvotes: 0

Ilya Demidov
Ilya Demidov

Reputation: 3305

Of course it's just pixel, not dp, but you always can convert it like that :

public static float convertDpToPixel(float dp,Context context){
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    float px = dp * (metrics.densityDpi/160f);
    return px;
}

Upvotes: 1

Related Questions