When i went through couple of android examples, in that i find some values are hard coded,
For eg:
<ImageView
android:id="@+id/icon"
android:layout_width="22px"
android:layout_height="22px"
android:layout_marginLeft="4px"
android:layout_marginRight="10px"
android:layout_marginTop="4px"
android:src="@drawable/ic_launcher" >
</ImageView>
In this image view values are hard coded, for my custom layout.. how to avoid these kinds of hard coding?
Is this the correct way in android?, does it have any impact on various screen size devices?
You need to read some developer docs:
http://developer.android.com/guide/practices/screens_support.html
http://developer.android.com/guide/practices/screens_support.html#screen-independence
NO:
Above will not scale well across screens
Yes:
Above will scale its pixels ‘independently’ per device
or
Above will draw itself relative to the screen size
or
Above will draw itself relative to the screen size and the other views on the screen
or
Above is created programmatically