android - Do I need to target devices for my application? -


i finished application, it's working expected on mobile phone, however, running on different avd it's disaster.

i have read article: http://developer.android.com/guide/practices/screens_support.html , articles too: http://developer.android.com/guide/topics/resources/index.html, don't know should do.

the min sdk 4.0 (api 14), , i'm targeting android 4.0.3 (api 15). want application run on mobile phones. know can set in androidmanifest.xml

do need create 7 individual layouts compatible different devices in portrait mode?

my problem views width, height , margins in dp. on different devices looks different. better understand i've attached image:

enter image description here

as can see, marked green portions spaces are.

what should have same design on different devices?

do need recreate design using relativelayout , reference views between them?

you shouldn't write whole new code other screens unless should differently in terms of positioning of elements. should define different values different screens, example: font size, margins, padding, etc.

for example in case, can make 3 separate dimens.xml files control marginbottom attribute according screen size it's being displayed on.

res/values/dimens.xml

<resources>     <!-- default (phones) -->     <dimen name="margin_bottom">45dp</dimen> </resources> 

res/values-sw600dp/dimens.xml

<resources>     <!-- 7'' tablets -->     <dimen name="margin_bottom">65dp</dimen> </resources> 

res/values-sw720dp-land/dimens.xml

<resources>     <!-- 10'' tablets -->     <dimen name="margin_bottom">75dp</dimen> </resources> 

and in main .xml file set this:

<textview ...     android:marginbottom="@dimen/margin_bottom" /> 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -