What is the unit for TextPaint setTextSize in Android?


The dev. docs does not say anything about the unit. Pixels, dps, cm? <a href="http://developer.android.com/reference/android/graphics/Paint.html#setTextSize(float)" rel="nofollow">http://developer.android.com/reference/android/graphics/Paint.html#setTextSize(float)</a>

From experimenting, the most likely answer is pixels, but I am not sure.


It is pixels, since setText() is native method and in Paint.h native call transforms the float to scalar value, then draws it. Of course, you can apply dip for support various screens by:

float textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, getResources().getDimension(R.dimen.text_size), getResources().getDisplayMetrics());


  • KeyVault --> Azure Pipeline --> XML variable substitution adds extra single quote to the end w
  • NSString and NSUrl not converting properly
  • How to place Compound drawable on top left of Text View
  • how to make android sweeping second hand on analog clock?
  • Why does boxing an array of function pointers with `box` syntax only work with a temporary `let` bin
  • AIrflow - Splitting DAG definition across multiple files
  • How do I change directory in command line with Clojure?
  • How to read STDIN into a variable in perl
  • 32bit rgb bmp to 24bit rgb bmp in C# problem
  • Is it Possible to get results of AsyncTask as an Arraylist Hashmap
  • having a condition to fragment adding
  • JPA+SQLite problem
  • function overloading in swift [duplicate]
  • Should I define variables in short blocks/functions of JavaScript? [closed]
  • Java Regex Finding digits in a String
  • Javascript matrix inversion
  • How to generate a SHA256 hash of 32 bytes using nodejs (crypto) in order to avoid bad key size error
  • How to use javascript to get information from the content of another page (same domain)?
  • How to enrich a TraversableOnce with my own generic map?
  • How to retrieve data from Firebase Database with join if key only return true?
  • using php to create an xml file from a mysql db
  • Open default mail app from within Qt with some html
  • Was default_marker removed from mapbox-gl.js
  • NodeJS - installing local module
  • NoSuchMethodError javax.ws.rs.core.Application.getProperties()Ljava/util/Map
  • how can i close the resultSet, prepareStatement, conn in several methods below to avoid rs close and
  • How can I access the Google account user_id?
  • MayAVI install on Python 3.6 [duplicate]
  • Extracting a small subset of data from XMLs
  • Ajax call on Multiple selection in Select box
  • Typeahead.js does give me suggestions but doesn't select them
  • Content-Type alternative in MQTT
  • how to get the location(lat/lng) on google maps v3 from the location(x,y)
  • How to turn off notice reporting in xampp?
  • how to run ejabberd with Erlang on Heroku?
  • Send array to next viewcontroller iOs xcode [duplicate]
  • Call Microservice from another Microservice within Docker