Here is The Code :
spinner.xml :
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="40dp"
android:maxLines="1"
android:gravity="center"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textSize="12sp" />
Spinner :
<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" />
Java :
array = new ArrayAdapter<String>(Activity.this,
R.layout.spinner, ArrayList);
array .setDropDownViewResource(R.layout.spinner);
Spinner.setAdapter(array );
Spinner.setOnItemSelectedListener(this);
Problem : Text is still Aligned to the Left
I've followed this : http://nevescheng.blogspot.fr/2013/05/spinner-with-item-text-aligned-to-center.html & this worked fine
I've noticed that i had another spinner xml in value-v11 Folder & this one was Not Modified, i've Modified it & its worked
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments