Align spinner values to right instead of left

回眸只為那壹抹淺笑 提交于 2019-12-09 08:18:40

问题


In spinner xml, I'm using:

 android:entries="@array/cars"

where cars is list of numeric items.

The spinner automatically align values to left, and I can't find in xml/code how to change it.


回答1:


You have to use a custom view here to give alignment to the Spinner values. Create a CustomView like this answer has created and add android:gravity to the TextView as right.

UPDATE:

Set the CustomView to your adapter using

adapter.setDropDownViewResource(android.R.layout.your_custom_created_view);



回答2:


You can use TextAlignment on properties and select TextEnd, or android:textAlignment="textEnd" on XML simple



来源:https://stackoverflow.com/questions/10629768/align-spinner-values-to-right-instead-of-left

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!