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