Forum Xamarin.Forms

How can I make the text wrap for long text in picker items

jdevxjdevx USMember
edited July 2014 in Xamarin.Forms

Is there a way to set the items in picker to wrap after they hit a certain length? I see that you can set the entire picker's widthrequest but that doesn't seem to do anything for long strings inside the picker's item list. Sample code below:

private readonly List<string> sampleQuestions = new List<string>
                                                                  "Long text goes here but I want it to wrap after X amount of width",
                                                                  "No wrap here"                                                                  

var myPicker = new Picker
                                                 HorizontalOptions = LayoutOptions.Center,                                                 
                                                 Title = "My picker",                                                 

 foreach (string pickerText in sampleQuestions)

Best Answer


  • tom3xtom3x SKMember

    I have a same problem.

    On Android: If there are some long text items in dialog window these items are centered and user cannot see begining of text and ending of text. For example item "This is very very long text item" is rendered like: "ry very long te"

    On iOS: Situation is OK for me because on iOS you can see begining of text and in the case of text overlapping item ends with ... So you see somethink like: "This is very very long..." It is OK.

    I would like to implement same behaviour as in IOS. Or if it's possible i would like to wrap text in android dialog or make fonts smaller.

    I have tried to use custom renderer but i cannot access to android picker dialog window (I think it is called spinner)
    I don't need wrapping text exactly but current behavior with centering text is unacceptable.

    Any ideas?
    Thank you.

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @tom3x, @jdevx:
    I would use ListViews instead of Pickers (I do so in my app because of the Picker-problems and behavior).
    I use also "Multiselect-Listviews" (where the user can select more then one item and a check is showed) or - with some changes in the logic - "Radiobutton-Listviews" (where the user only can select 1 item out of n and the active is showed with the check).
    If you are interested, you can find the description to the "Multiselect-LV" here:

  • tom3xtom3x SKMember

    Thank you Fredy. I will proceed with this aproach.

  • gabriel.6653gabriel.6653 USMember ✭✭

    Hi, if you are using a custom renderer can be the incorret inheritance.

    Use Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer not Xamarin.Forms.Platform.Android.PickerRenderer

    Tks to www.

Sign In or Register to comment.