首先我为 mini 2 制作应用程序并完美运行,但是当我尝试运行时,我想知道为什么我有一半的屏幕?,我得到的宽度值是 420?
WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); // the results will be higher than using the activity context object or the getWindowManager() shortcut
wm.getDefaultDisplay().getMetrics(displayMetrics);
wm.getDefaultDisplay().getMetrics(displayMetrics);
lebar = displayMetrics.widthPixels;
当我尝试使用lebar = (int) displayMetrics.widthPixels * displayMetrics.densityDpi;
我逼近了
07-17 22:28:26.994: E/AndroidRuntime(3936): FATAL EXCEPTION: main
07-17 22:28:26.994: E/AndroidRuntime(3936): java.lang.IllegalArgumentException: bitmap size exceeds 32bits
07-17 22:28:26.994: E/AndroidRuntime(3936): at android.graphics.Bitmap.nativeCreate(Native Method)
07-17 22:28:26.994: E/AndroidRuntime(3936): at android.graphics.Bitmap.createBitmap(Bitmap.java:691)
07-17 22:28:26.994: E/AndroidRuntime(3936): at android.graphics.Bitmap.createBitmap(Bitmap.java:668)
07-17 22:28:26.994: E/AndroidRuntime(3936): at android.graphics.Bitmap.createBitmap(Bitmap.java:601)
07-17 22:28:26.994: E/AndroidRuntime(3936): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:481)
07-17 22:28:26.994: E/AndroidRuntime(3936): at skripsi.slidame.slidameBoard.<init>(slidameBoard.java:84)
main.java
private final void createGameBoard(Bitmap gambar) {
board.once=true;
tableLayout = (TableLayout) findViewById(R.id.TableLayout1);
tableLayout.removeAllViews();
board = slidameBoard.createGameBoard(this,
gambar,
tableLayout,
lebar,
lebar,
ukurangrid);
board.setNumbersVisible(numbersVisible);
gambar.recycle();
}
第二个.java
public static slidameBoard createGameBoard(Context context,
Bitmap bitmap,
TableLayout parentLayout,
int width,
int height,
int gridSize) {
board = new slidameBoard(context,
bitmap,
parentLayout,
width,
height,
gridSize);
return board;
}