Align spinner values to right instead of left

2019-03-24 17:07发布

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.

2条回答
在下西门庆
2楼-- · 2019-03-24 17:26

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

查看更多
beautiful°
3楼-- · 2019-03-24 17:49

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);
查看更多
登录 后发表回答