android spinner 当前选中项如何右对齐?
android spinner
当前选中项如何右对齐?我的代码如下:
<Spinner android:id="@+id/houseSituation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:listitem="@android:layout/simple_spinner_item"
tools:itemCount="3"
/>
@Getter@Setter
public class KeyValueSpinnerAdapter extends ArrayAdapter<KeyValueSpinnerAdapter.Item> {
private final Spinner spinner;
@Data
@Accessors(chain = true)
public static class Item {
// ...
}
public KeyValueSpinnerAdapter(Context context, Spinner spinner, List<Item> items) {
super(context, android.R.layout.simple_spinner_item, items);
this.items = items;
this.spinner = spinner;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
Item item = this.items.get(position);
textView.setText(item.getName());
return textView;
}
}
回答:
<Spinner android:id="@+id/houseSituation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:listitem="@android:layout/simple_spinner_item"
tools:itemCount="3"
android:gravity="end"
/>
加一个样式 android:gravity="end"
解决。
以上是 android spinner 当前选中项如何右对齐? 的全部内容, 来源链接: utcz.com/p/945420.html