In my activity i am creating a Imageview dynamically. Every time it fetch the image from server create an imageview and set that image.
All images size also not same , so i want to put all images in a particular size. But its not working. Here is my code bellow,
ImageView imageView = new ImageView(getActivity());
imageView.setImageResource(mContent);
imageView.setPadding(20, 20, 20, 20);
imageView.setMaxWidth(400);
imageView.setMaxHeight(400);
LinearLayout layout = new LinearLayout(getActivity());
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
layout.setGravity(Gravity.CENTER);
layout.addView(imageView);
Simply do this,
imageview.getLayoutParams().height=100;
imageview.getLayoutParams().width=100;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.