Paint textPaint = new Paint(); textPaint.setTextSize(24); float textSize = textPaint.getTextSize(); // textSize will be 24
Paint textPaint = new Paint(); float scaledSizeInPixels = getResources().getDisplayMetrics().density * 24; textPaint.setTextSize(scaledSizeInPixels);In this example, we're retrieving the screen density (`getDisplayMetrics().density`) and using it to scale the text size to be appropriate for the device's screen. Package library: `android.graphics`