Creating device-specific custom Android Layouts -
my company ships android app preloaded on android device use industrial production equipment make. have both "phone" , "tablet" format devices, devices of different resolutions, locales, etc. i'm familiar having different xml folders "layout" "layout-land", different image resources "drawable-hdpi", "drawable-mdpi"; different language resources "values-ru", values-ro", etc.
now have customer wants load our app on own oddball aspect-ratio , resolution android device, supply with, want make custom layout device.
assuming make layout folder called "layout-custom1", how tell code use that layout folder instead of defaulting regular layout or layout-land folders? i'd in 1 place in code because our app has zillion screens/activities , i'd prefer not have in before calling every setcontentview().
and on subject, call can make in java ask device i'm running on?
edit: i'd prefer avoid having different apks because headache our production staff.
assuming make layout folder called "layout-custom1"
i think result in build error. if not, should, cannot invent new resource set qualifiers.
we have customer wants version of our app own oddball aspect-ratio , resolution android device want make custom layout device
ideally, find existing resource set qualifiers cover device, no other devices support.
or, use product flavors:
create 1 customer , 1 (empty) 1 else
override resources needed in customer-specific flavor
distribute customer-specific flavor's apk customer , other flavor else
otherwise, pretty stuck modifying each setcontentview()
call, use customer-specific resource when running on customer's device. can simplify via common resource id swizzling utility method, takes r.layout.foo
, returns r.layout.foo_funky
customer's device , r.layout.foo
other devices. then, modify setcontentview(r.layout.foo)
calls setcontentview(swizzler(r.layout.foo))
.
Comments
Post a Comment