I have an ImageView for which I want to pass float values as Top and Left margin. I have these 2 values to set as Top and Left margin.
float valTop = 3.5;
float valueLeft = 6.8;
I have this code. But I have to roundup the margin values to int value.
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.leftMargin = Math.round(valLeft);
params.topMargin = Math.round(valTop);
imageView.setLayoutParams(params);
Is there any way to directly set float value as margin ?