Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling an Android edit text so as to look like a drop down / spinner picker

I have two EditText views on a layout containing a date and a time. On being clicked these open up my custom DatePickerFragment and a TimePickerFragments. I would like to style the EditTexts with a picker drop corner as the following image shows.

target view

however I have not been able to do this, my text fields look like this:

my current view

The pickers all work and are hooked up and return values to the EditTexts, I just want to do the styling correctly. I am happy to change the class of the containers from EditText if they should be something else to get the desired behaviour. I think this should be possible as the first image comes from Google's own design documentation. Looking through the EditText and TextView class documentation and xml attibute documentation. Is there a way to do this?

I am using Xamarin to compile this down but that should make no difference to the answer.

like image 750
AlexC Avatar asked Dec 15 '22 18:12

AlexC


2 Answers

set the Style attribute to the following:

 <EditText
        style="?android:attr/spinnerStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
like image 67
Philipp Schumann Avatar answered May 13 '23 18:05

Philipp Schumann


use following image as background of your edittext

enter image description here

make it 9 patch with whatever colour you want.

like image 25
Ravi Avatar answered May 13 '23 19:05

Ravi