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.
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
@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.
where font
ReplyDeleteHi
To change font, add the .ttf font using font manager, and then in the code above add this:
DeletetextView1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/aire.ttf"), 0);
textView1.setBackgroundColor(Color.YELLOW);
Here aire.ttf is the font added using font manager.
How to set background color to spinner as well?
DeleteHow to do transparent background in spinner?
DeleteSuper job. You are the best! How can I edit spaces between items of spinner?
ReplyDeleteYou add following code to code above:
DeletetextView1.setHeight(300);
And vary the height
Nice work
ReplyDeleteHow can I changed background colour of spinner
ReplyDeletePlease help ( I was created app before add items it's work but after add items and latest feature adding don't working
ReplyDeleteHi comment crée UN sekbare rondy.
ReplyDeleteText Bold kase kare ?
ReplyDeleteCan I add photos?
ReplyDeleteHow to Listview font ?
ReplyDeletePage
ReplyDeleteHow to get child of child value from firebase in sketchware to appear on textview ?
ReplyDeleteexample:
ReplyDeleteZone:
Zone1:
"Zone_1A" : "1A"
"Zone_1B" : "1B"
"Zone_1C" : "1C"
Zone2:
"Zone_2A" : "2A"
"Zone_2B" : "2B"
"Zone_2C" : "2C"
Zone3:
"Zone_3A" : "3A"
"Zone_3B" : "3B"
"Zone_3C" : "3C"
How to get value of "Zone_1B" : "1B" in Sketchware to textview
Make reference to Firebase data location Zone.
ReplyDeleteIn onChildAdded,
If childKey equals Zone1,
textview1 setText( Map:childValue getkey Zone_1B)
Check this video: https://youtu.be/x0hXyDTBPUw
Can we add value from map to list string to be use on spinner?
ReplyDeleteHow to make spinner that get list from a STRING ARRAY?
ReplyDeleteCould we do that in sketchware?
How to change drawer font?
ReplyDeleteHow can I set multiple spinner ?
ReplyDelete