Android Spinner - Selected Value text is not aligning correctly

Multi tool use
Android Spinner - Selected Value text is not aligning correctly
I am trying to implement RtoL functionality in my application. The problem I'm having is with the Android Spinner. I have applied styled to the spinner to align everything as start
. This is working fine for the spinner items, but not for the selected text in the spinner. But when a new value is changed, the alignment fixes itself (aligns to right).
start
Below are the styles I have for the Spinner:
<style name="spinnerStyle" parent="android:Widget.DeviceDefault.Spinner">
<item name="android:gravity">start</item>
<item name="android:clickable">true</item>
<item name="android:spinnerMode">dropdown</item>
<item name="android:paddingStart">0dp</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_gravity">start</item>
<item name="android:textAlignment">viewStart</item>
<item name="android:paddingEnd">0dp</item>
</style>
This is what the spinner alignment is like when the view is first entered (with value already selected).
After I selected a new value, the alignment fixes itself:
Any ideas how I can fix that for the entry scenario?
@mTak this is using react-native
– Ricky Davis
Jul 3 at 9:09
1 Answer
1
When you initialize the ArrayAdapter, just use the android.R.layout.item1 for
Spinner to show each item.
spinner = ((Spinner) findViewById(R.id.spinner));
ArrayList<String> list = new ArrayList<String>();
list.add("Djibouti");
list.add("Egypt");
ArrayAdapter adapter2 = new ArrayAdapter(this, android.R.layout.simple_list_item_1,
android.R.id.text1, list);
spinner.setAdapter(adapter2);
I'm using react-native to handle the view creation.
– Ricky Davis
Jul 3 at 9:10
@RickyDavis Sorry, there is nothing i can do then
– D.Jiang
Jul 3 at 9:31
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Your style works fine. Can you post your spinner's xml?
– mTak
Jul 3 at 8:17