0

hi Im using spinner in my project . now I want to change font and size of text that shows in it . for this I have wrote new style in styles.xml but it is not working .

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorSecondary">#FFFFFF</item>
    <item name="android:spinnerItemStyle">@style/spinnerItemStyle</item>
    <item name="android:spinnerDropDownItemStyle">@style/spinnerDropDownItemStyle</item>
</style>
<style name="spinnerItemStyle">
    <item name="android:textColor">#f1f1</item>
    <item name="android:textSize">120sp</item>
    <item name="android:textStyle">bold</item>
</style>
<style name="spinnerDropDownItemStyle">
    <item name="android:textColor">#000000</item>
    <item name="android:textSize">20sp</item>
</style>
<Spinner
            android:id="@+id/spinner1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginStart="10dp"
            android:layout_marginLeft="161dp"
            android:layout_marginTop="15dp"
            android:focusable="true"
            android:layout_marginBottom="2dp"
            android:focusableInTouchMode="true"
            android:text="Notes"
            android:textColor="#000000"
            android:textSize="35sp"
            android:entries="@style/spinnerItemStyle"
            />

I have used the solution of this link but unfortunately it did not work https://stackoverflow.com/a/21174288/12020596

1 Answers1

0

One of the reason why its not working is because

 android:entries="@style/spinnerItemStyle"

This is wrong. android:entries should refer to some string array defined in the strings.xml. Like below

 <string-array name="spinner_values">
    <item>1</item>
    <item>2</item>
    <item>3</item>
</string-array>

Also the following properties are not needed for spinner

android:text="Notes"
android:textColor="#000000"
android:textSize="35sp"
akhil nair
  • 1,371
  • 1
  • 11
  • 19