Spinner Perzonalized Problem wide

1

I have this spinner with a perzonalized adapter, but the issue is that I'm not getting the expected result, at this moment it looks like this,

As you can see I have 2 arrows, one is from my custom layout, and the other one is the one that brings the spinner,

This is my Layout

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="textStart"
android:background="@drawable/redondo"
android:drawableEnd="@mipmap/flechaabajooo"/>

And so I set it

Spinner tipodePerfilSpinner = (Spinner) findViewById(R.id.SprTipoPerfil);

    ArrayList<String> Tipos = new ArrayList<>();
    Tipos.add("Persona");
    final  ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(InformationsPersonal.this,R.layout.spinner_custom,R.id.text1,Tipos);
    dataAdapter2.setDropDownViewResource(R.layout.spinner_custom);
    tipodePerfilSpinner.setAdapter(dataAdapter2);

    tipodePerfilSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
            Object tipo = dataAdapter2.getItem(position);
            TipoSeleccionado = tipo.toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapter) {
            //TODO implementar
        }

    });

The truth I was left without ideas because it does not occupy the whole width if it has android:layout_width="match_parent"

Apart from that it does not focus on what it should be.

or how to remove the arrow that brings the spinner by default, any help will be welcome, thank you already

    
asked by Bruno Sosa Fast Tag 08.11.2017 в 15:08
source

1 answer

1

Since you are using the style="?android:attr/spinnerItemStyle" style, the style of the spinner appears and you are also adding another date to your TextView android:drawableEnd="@mipmap/flechaabajooo"/> .

If you want to imitate the style of a Spinner, create a file called spinner_like.xml in the drawnable folder with the following:

<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">

    <corners android:radius="5dp" />
    <solid android:color="#ccc" />
    <stroke
        android:width="1dip"
        android:color="#ccc" />
</shape>

Then at your TextView you would change it like this:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="textStart"
android:background="@drawable/spinner_like"
android:drawableEnd="@mipmap/flechaabajooo"/>
    
answered by 08.11.2017 / 15:33
source