How to set spinner dropdown text direction to rtl
?
I know for regular texts we can use android:textDirection="rtl"
but it does not work for spinner dropdown text. Should I implement it in popup theme? How?
Thanks
How to set spinner dropdown text direction to rtl
?
I know for regular texts we can use android:textDirection="rtl"
but it does not work for spinner dropdown text. Should I implement it in popup theme? How?
Thanks
This will fix the issue.. enjoy
android:textAlignment="viewStart"
Try This -
Add below code in Activity
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.planets_array,
// android.R.layout.simple_spinner_item);
R.layout.textview);
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(R.layout.textview);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
textview.xml
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/spinnerItemStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" />
Change Gravity as per your requirement... Hope this will help...
First of all make sure that you enabled rtl support in AndroidManifest.xml
<application
...
android:supportsRtl="true"
...>
after that use this in your Spinner
definition :
android:layoutDirection="rtl"
android:textDirection="rtl"
© 2022 - 2024 — McMap. All rights reserved.