0
我想讓代碼工作,以便打開攝像機應用程序(此部分正在工作),但我不想它全屏。我希望攝像機在錄製過程中佔用一半(或更小)的屏幕。有誰知道這是可能的嗎? 我很新的android編程,所以任何幫助表示讚賞。攝像機使用意圖攝像機尺寸
public class MainActivity extends Activity {
private static final int PICTURE_RESULT = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button B1 = (Button) findViewById(R.id.button);
final Button B2 = (Button) findViewById(R.id.button2);
final Button B3 = (Button) findViewById(R.id.button3);
B1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.snoople);
}
});
B2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final int VIDEO = 1;
Intent intent = new Intent("android.media.action.VIDEO_CAMERA");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent, VIDEO);
finish();
}
});
B3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.camera);
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera, PICTURE_RESULT);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onBackPressed() {
startActivity(new Intent(this, MainActivity.class));
}
}