In my app i am inserting image from sdcard to imageview. How can i set image width=window width and image height will set automatic by Aspect ratio.
After this i will transform image by matrix.
i am using this code
int height;
int width;
String[] template_array;
ImageView imgTemplate;
int position = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery_image);
height = getWindowManager().getDefaultDisplay().getHeight();
width = getWindowManager().getDefaultDisplay().getWidth();
InitUI();
// InitPager();
DisplayImage();
SetonClickListners();
}
Set the image view's width to MATCH_PARENT, height to WRAP_CONTENT, and scaleType to centerInside. This will make it scale keeping aspect ratio, have a width of the full screen, and stop scaling the image such that it fits on the screen.
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.