Opinion about Android layout design to support multiple screens -
i'm developing android app needs support phones , tablets (minsdk:14). support mean layout , images (heights, widths, padding, margin, etc) should scale different screen sizes. don't need "different" layouts tablets such navigation drawer or rearranged layouts.
at first tried creating layout-sw600dp, layout-sw720dp... realized duplicating layouts , changing measures (heights, widths, etc). don't because difficult mantain in future.
instead left layouts in default /layout folder. created several dimens.xml , place them in folders /values, /values-sw600dp etc.
for /values/dimens.xml defined:
<dimen name="dp1">1dp</dimen> <dimen name="dp2">2dp</dimen> ... <dimen name="dp100">100dp</dimen>
for /values-sw600dp/dimens.xml defined:
<dimen name="dp1">2dp</dimen> <dimen name="dp2">4dp</dimen> ... <dimen name="dp100">200dp</dimen>
as can see, doubled dps tablets sw600.
then changed layouts measures (heights, widths, paddings, margins) use "@dimen/..."
this way layout seems scale in devices tested on. experts opinion on design election.
1) there problems approach?
2) can suggest better aproaches acomplish desired results?
thank you!
you doing correct using values resources. goal nothing related android related general programming practices of preventing redundant code , single place value change reflect everywhere. hope helps :)
Comments
Post a Comment