こんにちはどのようにこのコードを動作させるには?私は、このクラスCameraSurfaceView相対レイアウトの中に入れたいですか?Androidレイアウト:このViewGroupをRelativeLayout内に配置する方法は?
コード:
public class CameraSurfaceView extends ViewGroup implements SurfaceHolder.Callback{
private final String TAG = "Preview";
private SurfaceView mSurfaceView;
private SurfaceHolder mHolder;
private Size mPreviewSize;
private List<Size> mSupportedPreviewSizes;
private Camera mCamera;
public CameraSurfaceView(Context context) {
super(context);
mSurfaceView = new SurfaceView(context);
addView(mSurfaceView);
mHolder = mSurfaceView.getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
...
}
MainActivity。
public class MainActivity extends Activity{
RelativeLayout rlCamWrapper;
CameraSurfaceView cameraSurfaceView;
private SurfaceView surfaceView;
private boolean isRecording = false;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide the window title.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
cameraSurfaceView = new CameraSurfaceView(this);
setContentView(R.layout.main);
}
...
}
のxml:あなたの助けみんなのために先に
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/relativeLayout1"
android:orientation="horizontal"
android:weightSum="1.0"
>
<VideoView
android:id="@+id/videoView1"
android:layout_alignParentTop="true"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight=".5"/>
<RelativeLayout
android:id="@+id/surfaceViewWrapper"
android:layout_alignParentTop="true"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight=".5">
<SurfaceView
android:id="@+id/surfaceView2"
android:layout_alignParentTop="true"
android:layout_height="fill_parent" android:layout_width="fill_parent"
/>
</RelativeLayout>
</LinearLayout>
感謝。
@zrgiuはどういう意味ですか? – jayellos
申し訳ありませんが、フォーマットエラーです。編集された応答を確認してください – zrgiu
申し訳ありません@zrgiuが、私は本当にアンドロイドに新しいです、私はあなたが意味するものを得るが、私はそれをコードすることを知らない。サンプルコードを教えていただけますか?これは私がXMLで持っているものです。 –
jayellos