1

So I have several android.widget.Spinner for which I have set the android:spinnerMode="dialog"

For the resulting dialog windows I would like the title (set with android:prompt="Good Title") to be centered horizontally (but it keeps being placed at the start :S ).

I have tried the following to no avail (all my activities use my BaseTheme.DefaulTheme which ultimately inherits Theme.AppCompat.NoActionBar):

<style name="BaseTheme.DefaultTheme">
        <item name="android:alertDialogTheme">@style/CustomAlertDialogTheme</item>
        <item name="android:spinnerStyle">@style/CustomSpinnerStyle</item>
</style>
<style name="CustomAlertDialogTheme" parent="Theme.AppCompat.Dialog.Alert">
    <item name="android:windowMinWidthMajor">40%</item>
    <item name="android:windowMinWidthMinor">40%</item>
    <item name="android:windowTitleStyle">@style/DialogTitle</item>
</style>

<style name="DialogTitle">
    <item name="android:gravity">center_horizontal</item>
    <item name="android:textAlignment">center</item>
    <item name="android:layout_centerHorizontal">true</item>
</style>
<style name="CustomSpinnerStyle" parent="Widget.AppCompat.Spinner">
    <item name="android:gravity">center_horizontal</item>
    <item name="android:dialogTitle">@style/DialogTitle</item>
</style>

My targetSdkVersion is 24 and minSdkVersion is 19.

Overclover
  • 2,172
  • 1
  • 11
  • 11
  • 1
    refer http://stackoverflow.com/questions/7511049/set-view-text-align-at-center-in-spinner-in-android – sasikumar Nov 14 '16 at 07:52
  • That's the elements inside the spinner, not the title. There is also this http://stackoverflow.com/questions/4025605/custom-dialog-on-android-how-can-i-center-its-title which uses the builder for the alertdialog, but in this case it's a spinner – Overclover Nov 14 '16 at 07:55

0 Answers0