private void changeImagePos(AdInfo adinfo) { RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.height = mContext.getResources().getInteger(R.integer.ad_target_image_height); lp.width = mContext.getResources().getInteger(R.integer.ad_target_image_width); switch (mContext.getResources().getConfiguration().densityDpi) { case Constants.DENSITY_1280: lp.setMargins(adinfo.getPos_x(), adinfo.getPos_y(), 0, 0); break; case Constants.DENSITY_1920: lp.setMargins((int) (adinfo.getPos_x() * 1.5), (int) (adinfo.getPos_y() * 1.5), 0, 0); break; default: } mAdView.setLayoutParams(lp); }