1

私はターゲット レベル 2.1 の Android カメラ アプリに取り組んでいますが、フル スクリーン モードに入るときに難しいと感じました。プレビュー中にボタンを表示したいのですが、実際には非表示になっています。

これはこのウェブサイトで見つけたコードで、少し変更して ください http://marakana.com/forums/android/examples/39.html

    Preview preview;
    Button buttonClick;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cameralayout);

        preview = new Preview(this);
        ((FrameLayout) findViewById(R.id.preview)).addView(preview);

        setContentView(R.layout.cameralayout);

        buttonClick = (Button) findViewById(R.id.buttonClick);
        buttonClick.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                preview.camera.takePicture(shutterCallback, rawCallback, jpegCallback);
            }
        });
        Log.d(TAG, "onCreate'd");
    }

これはxmlです

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/preview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

            <Button
                android:id="@+id/buttonClick"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center|bottom"
                android:text="Click" />
</FrameLayout>

マニフェストはテーマを設定して全画面表示にします

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

それで、全画面プレビューのプレゼントで私のボタンを見えるようにする方法どうもありがとうございました〜

4

2 に答える 2

2

私はあなたがSurfaceViewビューを見逃していると信じています。FrameLayoutレイアウトの内側にSurfaceViewは、カメラのプレビューを保持する と下のボタンを配置します。

于 2012-07-18T15:46:28.963 に答える
0

行の後buttonClick = (Button) findViewById(R.id.buttonClick); にこれらの行を追加します

((FrameLayout) findViewById(R.id.preview)).removeView(buttonClick);
((FrameLayout) findViewById(R.id.preview)).addView(buttonClick);

今、あなたはあなたのボタンを見ることができます....

幸せな学習.. :)

于 2014-04-18T08:35:45.900 に答える