Hi Folks, we usually utilise dimens.xml file for r...
# android
p
Hi Folks, we usually utilise dimens.xml file for reusability across diff screens based upon some constraints like os version, screen size, etc. Can we create multiple dimens xml file but decide during runtime which dimens xml file to use based upon custom conditions?
not kotlin but kotlin colored 3
p
@Jeff Lockhart thanks, bt this only considers pre defined conditions such as screen size. I am looking more like : if(some condition) then flavor1/dimens else flavor2/dimens
j
Oh, I didn't fully read your question. No, I don't believe you can manually select which file is provided, as the
Context
determines what it returns.
I'd just create the possible dimensions as separate values in the XML and then your logic will access whichever one you need.
if (someCondition) dimen1 else dimen2