Changing text size and color of spinner in Sketchware

To change the text size and color of spinner dropdown list, follow the instructions given below.

1. In VIEW area of your Sketchware Android project, insert a Spinner spinner1.


2. In LOGIC area, add a new String list list1.

3. In onCreate event add items to the list.
4. After adding items to the String list, insert an add source directly block and put following code in it:

spinner1.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1, list1) {

@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView1 = (TextView) super.getView(position, convertView, parent);
textView1.setTextColor(Color.RED);
textView1.setTextSize(24);
return textView1; }

@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
TextView textView1 = (TextView) super.getDropDownView(position, convertView, parent); textView1.setTextColor(Color.RED);
textView1.setTextSize(24);
return textView1; }
});

5. Add the block spinner1 refreshData.

6. Save and run the project.

Note that in the code above:
- spinner1 is the id of spinner,
- list1 is the String list,
- getView(int position, View convertView, ViewGroup parent) is the view of spinner in inactive(when dropdown list is not visible) state,

- getDropDownView(int position, View convertView, ViewGroup parent) is the view of spinner in when dropdown list is visible,

- textView1 is the TextView in spinner array and all operations valid for a TextView can be performed on it.

In the code above android.R.id.text1 is the TextView in layout android.R.layout.simple_list_item_1.

https://youtu.be/Vph-S0xfAKg
http://www.sketchwarehelp.com/2018/03/changing-text-size-and-color-of-spinner.html