Android Spinner Set Dropdown Text Direction To Rtl
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 implemen
Solution 1:
This will fix the issue.. enjoy
android:textAlignment="viewStart"
Solution 2:
Try This -
Add below code in Activity
Spinnerspinner= (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(newMyOnItemSelectedListener());
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...
Solution 3:
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"
Post a Comment for "Android Spinner Set Dropdown Text Direction To Rtl"