How do I set a different theme for a Spinner's dropdown?

后端 未结 4 1792

An example usage:

The Spinner is dark themed, but I want the dropdown to be light themed.

4条回答
  •  孤城傲影
    2020-12-07 07:38

    for spinner's arrow I've used android:backgroundTint="@color/white" this will work from API 21

    for spinner view and dropdown view:

    ArrayAdapter areasAdapter = new ArrayAdapter(getContext(),R.layout.spinner_item, areas);
    
    areasAdapter.setDropDownViewResource(R.layout.dropdwon_item);
    areasSpinner.setAdapter(areasAdapter);
    

    for getView() the adapter will use spinner_item.xml

    for getDropDownView() the adapter will use dropdwon_item.xml

    then you can use your custom layouts as you like

    hope it helps

提交回复
热议问题