There is a picture in the project that shows a very small reason in the tablet. I have been suffering from failure to find the cause, and I have not tested it on the tablet. Today I found a resolution change, after writing the relevant method, record the comparison:
So that no wheels will be created in the future.
It is mainly used to obtain the image display problems related to the article. The getIntrinsicWidth () method is used to obtain the image. getIntrinsicWidth () is not the actual width of the image. It can be seen on the mobile phone without the difference being too far away, but on a tablet,
It is simply a little girl, so shy that the display is so small.
Back to the topic:
Solution:
1. Obtain the resolution of the mobile phone. Multiply the resolution by its density.
If (file. exists () {// if the file already exists, return Drawable drawable = Drawable. createFromPath (savePath); DisplayMetrics dm = new DisplayMetrics (); // get the cell phone screen resolution dm = context. getResources (). getDisplayMetrics (); // actual screen size // int screenWidth = dm. widthPixels; // int screenHeight = dm. heightPixels; float density = dm. density; // The actual image size int imgWidth = (int) (drawable. getIntrinsicWidth () * density); int imgHeight = (int) (drawable. getIntrinsicHeight () * density); // drawable. setBounds (0, 0, drawable. getIntrinsicWidth (), drawable. getIntrinsicHeight (); drawable. setBounds (0, 0, imgWidth, imgHeight); //} return drawable ;}
Load when no image is available
Private void setDrawable (Drawable nDrawable) {drawable = nDrawable; // drawable. setBounds (0, 0, drawable. getIntrinsicWidth (), drawable. getIntrinsicHeight (); // setBounds (0, 0, drawable. getIntrinsicWidth (), drawable. getIntrinsicHeight (); DisplayMetrics dm = new DisplayMetrics (); // get the cell phone screen resolution dm = context. getResources (). getDisplayMetrics (); // actual screen size // int screenWidth = dm. widthPixels; // int screenHeight = dm. heightPixels; float density = dm. density; // The actual image size int imgWidth = (int) (drawable. getIntrinsicWidth () * density); int imgHeight = (int) (drawable. getIntrinsicHeight () * density); // drawable. setBounds (0, 0, drawable. getIntrinsicWidth (), drawable. getIntrinsicHeight (); drawable. setBounds (0, 0, imgWidth, imgHeight); setBounds (0, 0, imgWidth, imgHeight); // note that if you add this parameter, the image and text will be confused}Address: http://hongshengpeng.com/article/show/254.aspx