Android 如何在攝像頭預(yù)覽的背景上加上一個手指可拖動的調(diào)節(jié)框?
問題描述
請問調(diào)節(jié)框該如何繪制?是在SufaceView 中繪制么?手指拖動如何實現(xiàn)?
啟動拍照功能后,下面是攝像頭預(yù)覽的背景(模擬器的),在這個背景上加上一個調(diào)節(jié)框
Activity代碼
public class PickActivity extends AppCompatActivity { private Button mBtnPick; private SurfaceView mSvView; private SurfaceHolder.Callback mCallback; private Camera mCamera; @Override protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_pick);initView();mCallback = new SurfaceHolder.Callback() { @Override public void surfaceCreated(SurfaceHolder holder) {startCamera(); } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } @Override public void surfaceDestroyed(SurfaceHolder holder) {stopCamera(); }};mSvView.getHolder().addCallback(mCallback);mBtnPick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {mCamera.takePicture(null, null, new Camera.PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) {File path = new File(Environment.getExternalStorageDirectory(), 'test');if (!path.exists()) { path.mkdirs();}File fileName = new File(path, 'test.jpg');try { FileOutputStream fos = new FileOutputStream(fileName); fos.write(data); fos.flush(); fos.close();} catch (IOException e) { e.printStackTrace();} }}); }}); } private void stopCamera() {mCamera.stopPreview();mCamera.release();mCamera = null; } private void startCamera() {mCamera = Camera.open();try { mCamera.setPreviewDisplay(mSvView.getHolder()); mCamera.setDisplayOrientation(90); mCamera.startPreview();} catch (IOException e) { e.printStackTrace();} } private void initView() {mBtnPick = (Button) findViewById(R.id.id_btn_pick);mSvView = (SurfaceView) findViewById(R.id.id_sv_camera); }}
問題解答
回答1:添加seekBar
相關(guān)文章:
1. 調(diào)用百度翻譯API,在JAVA項目可以翻譯,在android中卻不行。求助2. 在應(yīng)用配置文件 app.php 中找不到’route_check_cache’配置項3. javascript - 給頁面加了動畫,在微信瀏覽器中顯示混亂,急救4. javascript - vue 獲取json數(shù)據(jù)的某個屬性成功,卻報錯5. 老師,layui.css無法使用,路徑都是按照視頻照做的,是不是還有其他步驟需要做?6. html5 - 只用CSS如何實現(xiàn)input框的寬度隨框里輸入的內(nèi)容長短自動適應(yīng)?7. phpadmin的數(shù)據(jù)庫,可以設(shè)置自動變化時間的變量嗎?就是不需要接收時間數(shù)據(jù),自動變化8. javascript - 使用nunjucks 如何修改模板目錄?9. css3動畫 - CSS3 transition動畫屬性指定前后問題10. python - Ubuntu16.04LTS登錄后只顯示屏保