Reputation: 309
How to align the text to the center of the spinner?
code that I am using:
<Spinner android:id="@+id/s_change_type"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:textAlignment="center"
style="@style/Spinner"
android:layout_height="wrap_content"/>
Spinner:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:singleLine="true"
style="?android:attr/spinnerItemStyle"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:textAlignment="inherit"
android:padding="10dp"
android:layout_margin="5dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"/>
Style used by spinner:
<style name="Spinner"
parent="Widget.AppCompat.Spinner.Underlined">
<item name="android:textColor">@color/color_text</item>
<item name="android:textSize">12sp</item>
<item name="android:paddingLeft">@dimen/margin_general_left</item>
<item name="android:paddingRight">@dimen/margin_general_right</item>
</style>
Thanks
Upvotes: 5
Views: 605
Reputation: 1229
In your TextView
write:
android:layout_width="match_parent"
Instead of:
android:layout_width="wrap_content"
Upvotes: 5