Set margins in dp programmatically – Android

Sometimes at runtime, it is required to set margin to a view. But, the problem is getting different size for different screen sizes, i.e. hdpi, xhdpi, xxhdpi, etc. This could be done easily with the help of screen specific value resources. Provide screen specific dimension values/dimen.xml <dimen name="margin_top_list_item">2dp</dimen> (more…)
Read More