开发者

Style Editor - dynamically create and apply styles

开发者 https://www.devze.com 2023-02-16 19:14 出处:网络
I\'m developing an app for text reading. I\'m trying to increase the options for my users to customize the appearance of the text and t开发者_Python百科he app itself. Creating multiple styles in my re

I'm developing an app for text reading. I'm trying to increase the options for my users to customize the appearance of the text and t开发者_Python百科he app itself. Creating multiple styles in my resources folder and switching among them at runtime seems simple enough using the view constructors that take a style parameter.

However I'm also considering going one step further and creating a style editor in my application that allows users to have full control over their experience.

I think that doing this using Android styles is basically out of the question, since the style ids are generated at compile time. I'm considering creating custom views that are light wrappers around the views that I need styled, manipulating the AttributeSet in the view constructor to apply my styles.

How should I dynamically create and apply styles to my views?


your approach is quite right as i tried several posts in several places, if you don't do it yourself, it wont be done :-) Android does not support dynamic theme as it seems. I wanted mine to be downloadable as a plugin, you need, as you say create a wrapper and be able to extract extra parameters from the AtrributeSet OR add an extra HashTable parameter with the attributes you want to override.

0

精彩评论

暂无评论...
验证码 换一张
取 消