Hi I want to set the style and size for a text in spinner programatically(Dynamically).I don't use any resources in my app for this.So give me some suggestions for this
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
same as custom listview we can set the values to the spinner .in the customview class we can set the properties to the Textview
I dont think you can create this dynamically without overriding the behavior of the default layout resources . To create it using resources:
Create a layout file containing a
TextView
and define the size,colors and other style for this. And create anArrayAdapter
object and provide that layout file in your adapter alongwith theID
of theTextView
.Your layout file will be like this: spinner_item.xml
Now you can use this in your code like this:
Also you can create a custom ArrayAdapter and overriding the methods
getView()
orgetDropDownView()
inside this methods you can set custom color, size and fonts for your
TextView
Update:
I have changed the text size and color of the spinner items dynamically by overrding the default resources of android. The snippet I have used is as given below:
I have made 2 modifications,
1-added another constructor so that one can use a resource 2-added 2 public function (setTextSize, and getTextSize) (3-Also disabled the color by putting them as comments)