Spinner with a call icon

0

Hello, I'm trying to make a spinner with the options: "Open Today" and "It Does not Matter."

In my layout, I do not want anything written but a clock icon, which when clicked loads the spinner list.

I put the image in the background of the spinner.

It happens that it expands as the list option is selected, can you leave it as a fixed size?

And also the other question is will be that the list with the options can be added only in position 1, because as I do not know this, I'm adding the first element of the list as "" so that the layout is only the image. / p>

I tried to put it as a listheader, but it did not work. Thank you! What I'm using:

No Layout:
 <Spinner
android:id="@+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:scrollIndicators="end"
android:textAlignment="center"
android:background="@drawable/local" />

No código:
horario = new ArrayList<>();
horario.add("");
horario.add("Aberto Hoje");
horario.add("Não importa");
adapter = new ArrayAdapter<String>(getApplication(), android.R.layout.simple_spinner_dropdown_item, horario);
    spinnerhora.setAdapter(adapter);
    
asked by anonymous 03.12.2016 / 16:20

1 answer

0
  

No Layout

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/image3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/imagem"/>
    <Spinner
        android:id="@+id/spinner3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center_horizontal"
        android:scrollIndicators="end"
        android:textAlignment="center"
        android:background="@drawable/local"
        android:visibility="gone" />
</RelativeLayout>
  

In the code

Spinner spinner3 = (Spinner) findViewById(R.id.spinner3);
ImageView image3 = (ImageView) findViewById(R.id.image3);

ArrayList horario = new ArrayList<>();    
horario.add("Aberto Hoje");
horario.add("Não importa");
ArrayAdapter adapter = new ArrayAdapter<String>(getApplication(), android.R.layout.simple_spinner_dropdown_item, horario);
spinner3.setAdapter(adapter);

image3.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        spinner3.setVisibility(View.VISIBLE);
    }
});
    
05.12.2016 / 20:26