Spinner autowidth

Brad

Active Member
Licensed User
Longtime User
Is there a way for the spinner to auto size to the selected text like it does in Java?
 

klaus

Expert
Licensed User
Longtime User
Yes, set the width of the Spinner to -2.
B4X:
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Spinner1.Width=-[/SIZE][/FONT][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
Width can have two special values:
-1 fill_parent / match_parent
-2 wrap_content

Attached a small test program.
If the text length is wider than the device width, the Spinner width is set to the device width.
In this case, if the Left property is >0 then a part of the right side of the Spinner will be out of the screen.

Best regards.
 

Attachments

  • SpinnerAutoWidth.zip
    5.8 KB · Views: 378
Last edited:
Upvote 0
Top