我试图让代码工作,以便我打开摄像机应用程序(这部分目前正在工作),但我不希望它全屏显示。我希望摄像机在录制过程中占据屏幕的一半(或更小)。有人知道这是否可能吗?我对 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));
}
}