How to remove the separator line in the spinner?
Asked Answered
C

3

6

How to remove the separator line in the spinner?

For example, how can I remove/control these white separator lines?

spinner

P.S. This is the row layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black">

    <TextView
    android:id="@+id/catalog_spinner_item_textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="11dp"
    android:text="@string/CatalogSpinnerItemRowDefaultText"
    android:textSize="18sp"
    android:gravity="center_vertical"/>
</LinearLayout>
Cystoscope answered 8/4, 2013 at 12:34 Comment(4)
check this out : https://mcmap.net/q/854946/-android-cannot-style-spinner-dividerKnighthead
This answer regards change the Theme for all the application/all spinners in the application. I need a solution for specific spinner.Cystoscope
@Cystoscope did you figure it out?Underline
@Underline check first commentCystoscope
H
3
public View getView(int position, View row, ViewGroup container) {
    row=(View) inflater.inflate(R.layout.row_layout_spinner_filter, null);
    TextView tv=(TextView) row.findViewById(R.id.textview_spinner_filter_item_name);
    if(container!=null&&(container instanceof ListView)){
        ListView lv=null;
        try{
            lv=(ListView)container;
        }catch(Exception e){}
        if(lv!=null){
            lv.setDivider(drawable);
            lv.setDividerHeight(height);
        }
    }
    tv.setText(getItem(position));
    return row;
}

ViewGroup container comes as ListView or Spinner, so you can catch listview and edit divider.

Hereditament answered 26/8, 2015 at 13:22 Comment(0)
B
0

use in Spinner's xml

android:backgorund="@null"

Bolger answered 1/6, 2017 at 9:13 Comment(0)
E
-1

Define a style as mentioned by Kunal, then refer to that style in your spinner as android:style = " "

or you can use android:divider and android:dividerHeight in your spinner to control its attributes/ remove them.

Or you can set the divider to android:color/transparent as well.

Earthshaker answered 17/1, 2014 at 18:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.