我使用它作为一个例子它很好用(相机api,而不是camera2):http://examples.javacodegeeks.com/android/core/hardware/camera-hardware/android-camera-example/
但是,如何使用+和 - 两个按钮实现放大/缩小?!? 已经搜索了几个小时而且还没有。
非常感谢你。
答案 0 :(得分:0)
试试这段代码,应该会有所帮助: -
case MotionEvent.ACTION_MOVE:
if (mode == ZOOM) {
float newDist = spacing(event);
double zoomDist = newDist-oldDist;
if(zoomDist > 0){
if(zoomDist > 50 && zoomDist <= 200){
if (curZoomLevel < mZoomMax && gestureZoom == 0) {
gestureZoom ++;
GestureZoomIn();
}
}else if(zoomDist > 200 && zoomDist <= 300){
if (curZoomLevel < mZoomMax && gestureZoom == 1) {
gestureZoom ++;
GestureZoomIn();
}
}else if(zoomDist > 300 && zoomDist <= 400){
if (curZoomLevel < mZoomMax && gestureZoom == 2) {
gestureZoom++;
GestureZoomIn();
}
//zoomin
private void GestureZoomIn(){
if (mParameters.isZoomSupported()){
mZoomMax = mParameters.getMaxZoom();
if (zoom_text_value<mZoomMax) {
zoom_text_value++;
curZoomLevel++;
zoom_float=zoom_float+0.5;
onZoomValueChanged(curZoomLevel);
//zoomout
private void GestureZoomOut(){
if (mParameters.isZoomSupported()){
if (0<zoom_text_value) {
zoom_text_value--;
curZoomLevel--;
zoom_float=zoom_float-0.5;
onZoomValueChanged(curZoomLevel);
由于