T
T
Tsuzukeru2021-08-30 13:14:15
Android
Tsuzukeru, 2021-08-30 13:14:15

How to make Spinner DropDown with rounded corners?

I need to customize the Spinner DropDown to have rounded corners.
screenshot

Tried to make the color transparent using this solution . Did not help.

Layout:

<androidx.appcompat.widget.AppCompatSpinner
        android:id="@+id/messageSubject"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:textAppearance="@style/Text.Default.Normal"
        android:background="@color/transparent"
        android:minHeight="@dimen/grid_6_25"
        android:layout_marginTop="@dimen/grid_1_75"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/supportQuestion" />


Fragment:

class SupportFragment : Fragment(R.layout.fragment_support) {

    private val viewBinding by viewBinding<FragmentSupportBinding>()

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }

    private fun initView() {
        val adapter = ArrayAdapter.createFromResource(
            requireContext(),
            R.array.message_subject,
            R.layout.spinner_selected
        ).also { adapter ->
            adapter.setDropDownViewResource(R.layout.spinner_dropdown)
        }

        viewBinding.messageSubject.adapter = NothingSelectedSpinnerAdapter(requireContext(), adapter, R.layout.spinner_hint)
    }

    companion object {
        fun newInstance() = SupportFragment()
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question