Calculating the size of a label text RRS feed

  • Question

  • User81589 posted

    Is there a was to calculate the dp size of a label with a specific text and a specifc font(size).


    I want to be sure that a given text is shown on any device. If the text does not fit completly in the label, I want to decrease the font size until all the text is shown in the label.

    Any ideas?


    Friday, January 9, 2015 10:23 AM

All replies

  • User31231 posted

    Hi @K.Seybold,

    Which platform Android or iOS?



    Friday, January 9, 2015 3:09 PM
  • User81589 posted

    Both, it a shared assembly (Android / iOS)

    Friday, January 9, 2015 3:18 PM
  • User31231 posted

    In a shared assembly, no you'll have to go platform specific on that one because each OS handles the process differently.

    Friday, January 9, 2015 3:20 PM
  • User81589 posted

    OK, can you give me the soilution for iOS and Android?

    Friday, January 9, 2015 3:47 PM
  • User12403 posted

    For iOS you would use GetBoundingRect method on NSString. Here is a sample on how to calculate string height:


    Friday, January 9, 2015 3:53 PM
  • User81589 posted

    @SKall: Thanks for the iOS solution.

    Is there any solution for Android?

    Monday, January 12, 2015 9:32 AM
  • User195916 posted

    @K.Seybold Did u find a solution for android?

    Friday, October 21, 2016 10:18 AM
  • User87950 posted

    I'd like to have an answer for Android as well.

    Wednesday, May 20, 2020 5:37 PM