如何旋转ImageButton根据相机旋转?

时间:2013-10-04 14:36:31

标签: android layout camera

我正在制作自定义相机布局。它有一个framelayout和imagebutton。我想根据相机旋转旋转此按钮。因此每当我在“图像”按钮中旋转相机时,应该朝向正确的方向 但我无法弄清楚如何做到这一点。这是我的代码......

public class CameraActivity extends Activity
{
protected void onCreate(Bundle savedInstanceState) {    
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        // Get an instance of the WindowManager
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        mDisplay = mWindowManager.getDefaultDisplay();

        setContentView(R.layout.camera_layout);


        btnCapture = (ImageButton)findViewById(R.id.btn_capture);       
        mCamera = getCameraInstance();
        mPreview = new CameraPreview(this, mCamera);
        FrameLayout camPreview = (FrameLayout)findViewById(R.id.camera_preview);
        camPreview.addView(mPreview);   
    }
}

0 个答案:

没有答案
相关问题