Material design Spinner using TextInputLayout.OutlinedBox styling

前端 未结 8 1094
暗喜
暗喜 2021-02-05 11:31

I am currently using Material Design TextInputLayout OutlinedBox as shown below:

        

        
相关标签:
8条回答
  • 2021-02-05 12:03

    I am using the below material libs to get spinner

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    

    Here is my layout look like

     <com.google.android.material.textfield.TextInputLayout
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                android:layout_width="500dp"
                android:layout_height="wrap_content"
                android:hint="@string/select_wifi"
                app:hintTextAppearance="@style/hintStyle"
                app:startIconDrawable="@drawable/wifi">
    
                <com.google.android.material.textfield.MaterialAutoCompleteTextView
                    style="@style/textInputEdittext"
                    android:inputType="none" />
    
            </com.google.android.material.textfield.TextInputLayout>
    

    Check out this image for the spinner

    0 讨论(0)
  • 2021-02-05 12:06

    I solved my problem using this: in XML:

    <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/layout"
            style="@style/AppTheme.ExposedDropdownMenu"                        
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <AutoCompleteTextView
                android:id="@+id/my_spinner_dropdown"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
        </com.google.android.material.textfield.TextInputLayout>
    

    in code:

            layout.keyListener=null
            ArrayAdapter(it, android.R.layout.simple_list_item_1, list).also { 
             adapter ->
                layout.setAdapter(adapter)
            }
    

    Credits:How to make EditText not editable through XML in Android?

    0 讨论(0)
提交回复
热议问题