public void shiftImage(int leftDPIs) { if (leftDPIs > 0) { DisplayMetrics metrics = new DisplayMetrics(); surfaceView.getWindowManager().getDefaultDisplay().getMetrics(metrics); pixels = (int) (leftDPIs * metrics.density + 0.5f); Log.i("frodo64", "pixels: " + pixels); scaleX = (float) (width - pixels) / bufferWidth; scaleY = (float) height / bufferHeight; coordsChanged = true; if (bitmap != null) bitmap.changeCoords(pixels, 0, scaleX, scaleY); } else { pixels = 0; scaleX = (float) width / bufferWidth; scaleY = (float) height / bufferHeight; coordsChanged = true; if (bitmap != null) bitmap.changeCoords(0, 0, scaleX, scaleY); } Log.i("UAE", "new scale: " + scaleX + "-" + scaleY + "-" + pixels); if (width < height) { scaleY = scaleX; } }
// @Override // public void onClick(View v) {//直接调用不会显示v被点击效果 // switch (v.getId()) { // case R.id.ivDemoMainReturn: // enterAnim = R.anim.fade; // exitAnim = R.anim.bottom_push_out; // finish(); // break; // case R.id.ivDemoMainMenu: // showTopMenu(); // break; // // case R.id.ivDemoMainHead: // selectPicture(); // break; // case R.id.tvDemoMainHeadName: // editName(true); // break; // // case R.id.llDemoMainItemOnlyDialog: // showItemOnlyDialog(); // break; // case R.id.llDemoMainMyAlertDialog: // showMyAlertDialog(); // break; // // case R.id.llDemoMainSelectPictureActivity: // selectPicture(); // break; // case R.id.llDemoMainCutPictureActivity: // cutPicture(picturePath); // break; // case R.id.llDemoMainWebViewActivity: // toActivity(WebViewActivity.createIntent(context, "百度首页", "www.baidu.com")); // break; // case R.id.llDemoMainEditTextInfoActivity: // editName(false); // break; // case R.id.llDemoMainDemoActivity: // toActivity(DemoActivity.createIntent(context, null)); // break; // case R.id.llDemoMainDemoFragmentActivity: // toActivity(DemoFragmentActivity.createIntent(context, null)); // break; // case R.id.llDemoMainDemoTimeRefresherActivity: // toActivity(DemoTimeRefresherActivity.createIntent(context)); // break; // case R.id.llDemoMainTopMenuWindow: // showTopMenu(); // break; // case R.id.llDemoMainBottomMenuWindow: // toActivity(BottomMenuWindow.createIntent(context, "选择颜色", topbarColorNames), // REQUEST_TO_BOTTOM_MENU, false); // break; // case R.id.llDemoMainEditTextInfoWindow: // editName(true); // break; // case R.id.llDemoMainDatePickerWindow: // toActivity(DatePickerWindow.createIntent(context, new int[]{1971, 0, 1} // , TimeUtil.getDateDetail(System.currentTimeMillis())), REQUEST_TO_DATE_PICKER, false); // break; // case R.id.llDemoMainPlacePickerWindow: // toActivity(PlacePickerWindow.createIntent(context, 2), REQUEST_TO_PLACE_PICKER, false); // break; // default: // break; // } // } // Library内switch方法中case R.id.idx:报错 @Override public void onClick(View v) { // 直接调用不会显示v被点击效果 if (v.getId() == R.id.ivDemoMainReturn) { enterAnim = R.anim.fade; exitAnim = R.anim.bottom_push_out; finish(); } else if (v.getId() == R.id.ivDemoMainMenu) { showTopMenu(); } else if (v.getId() == R.id.ivDemoMainHead) { selectPicture(); } else if (v.getId() == R.id.tvDemoMainHeadName) { editName(true); } else if (v.getId() == R.id.llDemoMainItemOnlyDialog) { showItemOnlyDialog(); } else if (v.getId() == R.id.llDemoMainMyAlertDialog) { showMyAlertDialog(); } else if (v.getId() == R.id.llDemoMainSelectPictureActivity) { selectPicture(); } else if (v.getId() == R.id.llDemoMainCutPictureActivity) { cutPicture(picturePath); } else if (v.getId() == R.id.llDemoMainWebViewActivity) { toActivity( WebViewActivity.createIntent( context, SettingUtil.isOnTestMode ? "测试服务器网址" : "正式服务器网址", SettingUtil.getCurrentServerAddress(context))); } else if (v.getId() == R.id.llDemoMainEditTextInfoActivity) { editName(false); } else if (v.getId() == R.id.llDemoMainDemoActivity) { toActivity(DemoActivity.createIntent(context, 0)); } else if (v.getId() == R.id.llDemoMainDemoFragmentActivity) { toActivity(DemoFragmentActivity.createIntent(context, null)); } else if (v.getId() == R.id.llDemoMainDemoTabActivity) { toActivity( DemoTabActivity.createIntent(context).putExtra(DemoTabActivity.INTENT_TITLE, "Yes!")); } else if (v.getId() == R.id.llDemoMainDemoTimeRefresherActivity) { toActivity(DemoTimeRefresherActivity.createIntent(context)); } else if (v.getId() == R.id.llDemoMainTopMenuWindow) { showTopMenu(); } else if (v.getId() == R.id.llDemoMainBottomMenuWindow) { toActivity( BottomMenuWindow.createIntent(context, topbarColorNames) .putExtra(BottomMenuWindow.INTENT_TITLE, "选择颜色"), REQUEST_TO_BOTTOM_MENU, false); } else if (v.getId() == R.id.llDemoMainEditTextInfoWindow) { editName(true); } else if (v.getId() == R.id.llDemoMainDatePickerWindow) { toActivity( DatePickerWindow.createIntent( context, new int[] {1971, 0, 1}, TimeUtil.getDateDetail(System.currentTimeMillis())), REQUEST_TO_DATE_PICKER, false); } else if (v.getId() == R.id.llDemoMainPlacePickerWindow) { toActivity( PlacePickerWindow.createIntent(context, getPackageName(), 2), REQUEST_TO_PLACE_PICKER, false); } }