I created a custom spinner
and custom dropdown spinner
, when using them, the selector will be almost invisible and its color will not help either. I wanted my spinner selector to be larger, it could be the default size and I wanted another color, so I would go to the bottom of the layout. is in bold is my problem)
I tried to pass a color reference to the attribute in xml android:dropDownSelector
and it still did not work. I'm going to put images here of two spinners.
Thisimagereferstoastandardspinner.Createdwiththislayout:android.R.layout.simple_spinner_item
andthenthedropdownlayoutconfiguredthisway:android.R.layout.simple_spinner_dropdown_item
noadapter.Intheimageabovethespinnerwasnottouchedbytheuser,theimagebelowreferstothesamespinneronlywiththedifferencethatitisbeingtouchedbytheuser.
Now if by chance I use a custom spinner and a custom dropdown for the adapter, the selector gets almost invisible as I said. Let's now see pictures of how my custom spinner got.
Thesamecustomspinnerbelowjustnowselected.
Below is the code for my custom spinner and custom spinner dropdown.
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>
Again remembering. I want the selector of my custom spinner
to be larger and have a different color to go out to the bottom. The selector size could be the size of the default selector. I would also like to know why when I used a custom spinner
the selector size was almost invisible and not the original size.
layout of the fragment:
<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>