0
I created a custom spinner and a custom dropdown spinner, when using them, the selector is almost invisible and its color also does not help. I wanted my spinner selector to be bigger, it could be the default size and wanted another color, to get over the background of the layout. (This bold is my problem)
I tried passing a color reference to the attribute in xml android:dropDownSelector and yet it didn’t work. I’ll put pictures here of two spinners.

This image refers to a standard spinner. Created with this layout: android.R.layout.simple_spinner_item and then the dropdown layout configured this way: android.R.layout.simple_spinner_dropdown_item on the Adapter. In the image above the spinner was not touched by the user, the image below refers to the same spinner only with the difference that it is being touched by the user.

Now if I happen to use a custom spinner and a custom dropdown for the Adapter, the selector is almost invisible as I said. Let’s see now images of how my custom spinner turned out.

The same custom spinner below only now selected.

Below follows the code of my custom spinner and custom spinner dropdown(This is configured in Adapter)
custom_spinner_item.xml
<TextView
android:id="@+id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="#fff"/>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="#fff"/>
</LinearLayout>
custom_spinner_dropdown_item.xml
<LinearLayout
android:id="@+id/linearLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#232323"
android:orientation="horizontal">
<TextView
android:id="@+id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="#fff"/>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="#fff"/>
</LinearLayout>
Once again remembering. I want the selector of mine custom spinner be larger and have a different color for about hanging out in the background. The size of the selector could be the size of the default selector. I’d also like to know why when I used one custom spinner the size of the dial has become almost invisible and not the original size.
Fragment layout:
<LinearLayout
android:id="@+id/layoutMain"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#0F2028"
android:orientation="vertical"
android:padding="5dp">
<Switch
android:id="@+id/switchButtonConcluidoIM"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/concluido"
android:textColor="#ffffffff"
android:textOff="@string/nao"
android:textOn="@string/sim"/>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:id="@+id/tableRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textViewPrimario"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/primario"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#55b76b"
android:textStyle="bold"
/>
<Spinner
android:id="@+id/spinnerPrimario"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/textViewSecundario"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/secundario"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#55b76b"
android:textStyle="bold"/>
<Spinner
android:id="@+id/spinnerSecundario"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:id="@+id/textViewLeitura"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/leitura"
android:textColor="#ffffff"/>
<EditText
android:id="@+id/editTextLeitura"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_weight="2"
android:background="@drawable/fields_border"
android:ems="10"
android:inputType="numberDecimal"/>
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:id="@+id/textViewPolaridade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/polaridade"
android:textColor="#ffffff"
/>
<EditText
android:id="@+id/editTextPolaridade"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_weight="2"
android:background="@drawable/fields_border"
android:ems="10"
android:inputType="numberSigned"/>
</TableRow>
<TableRow
android:id="@+id/tableRow5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:id="@+id/textViewObs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/observacao"
android:textColor="#ffffff"
/>
<EditText
android:id="@+id/editTextObs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="2"
android:background="@drawable/fields_border"
android:ems="10"/>
</TableRow>
</TableLayout>
</TableLayout>
</ScrollView>
Lucas, take a look at this OS question http://stackoverflow.com/questions/13703233/style-android-spinner. There he wanted to style the dropdown items, but he also styled the "arrow". Maybe that’s a good place to start
– Wakim
@Wakim I’ll take a look and then I’ll give back.
– Lucas Santos
Another tip, from an inspected one (with ddms) on the width of the dropdown items. Maybe the width of the items is causing the problem and pushing the arrow.
– Wakim
Is it? I put mine
TextViewofcustom spinnerasmatch_parent, I’ll try to change later towrap_contentand see if there are any changes to the size of the selector.– Lucas Santos
@Wakim the link didn’t help me... :( As for the change in the width of the
TextViews, nothing happened, I did the tests and the selector remains small.– Lucas Santos
I could post the layout of Activity or Fragment?
– Wakim
@Wakim, I will edit my question with the layout of Fragment. As for the color of the selector, I managed to solve it. My problem is still in the
custom layout, got the cool color the selector, but it is still small. If I managed to solve everything here I put the solution. I am navigating between thestylesandroid API to see the components and make the changes.– Lucas Santos
@Wakim before I edit the answer with the code from
fragment, you think it really necessary to put the code here?– Lucas Santos
Code is not required, only the same layout
– Wakim
Sorry, I messed up the code. Posting in 1...2...3...
– Lucas Santos
Lucas, try to exchange fill_parent for match_parent. Fill is deprecated... Soon I take a closer look at the layout.
– Wakim
Android Studio that puts this F#@R@#(*U(#@ de
fill_parentautomatic so I forget to switch tomatch_parent.– Lucas Santos
Okay, I got the briefcase
resand sent a replace offill_parentformatch_parent. All the files they hadfill_parentwere changed and yet the almost invisible selector problem in thecustom layoutpersists. I’m glad there’s replace :)– Lucas Santos
@Wakim found the problem. o/ But I still don’t understand why. I tried to put mine
spinner fora datablerowe advinha? Taram!!! Lá estava o seletor grande. Por algum motivo ele dentro dotablerow` stays that way.– Lucas Santos
@Wakim managed to solve the problem. I will post the solution.
– Lucas Santos