そのため、カメラのプレビューを背景として表示し、その上にイメージビューを表示しようとしています。私が何を達成しようとしているのかをよりよく理解するために、私が尋ねたこの質問をチェックしてください。ただし、FrameLayoutを使用する代わりに、RelativeLayoutを使用する方が簡単であることがわかりました(画面上の目的の場所にビューを配置するため)。問題は、画面全体を占めるイメージビュー(サーフェスビュー上)を取得できないことです。画像のサイズをどのように変更しても、画面がいっぱいになることなく中央に表示されます。
だから、私の質問は、どのように画像ビューを表面ビューの画面全体に塗りつぶすのですか?簡単な間違いをしているのかもしれませんが、その場合は指摘してください。どんな助けでも大歓迎です!ありがとう!
XMLファイルは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/relative" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/image"
android:src="@drawable/background" >
</ImageView>
<Button
android:id="@+id/scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:text="Scan"
android:textSize="20dp"
android:textStyle="bold"
android:onClick="Scan" />
<Button
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/scan"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:text="Search"
android:textSize="20dp"
android:textStyle="bold"
android:onClick="Search" />
<Button
android:id="@+id/importing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/search"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:text="Import"
android:textSize="20dp"
android:textStyle="bold"
android:onClick="Import" />
</RelativeLayout>
そして、これがビューを配置するコードです(サーフェスビュー上に表示されるように前面に移動します)。
mPreview = new CameraPreview(this, mCamera);
relative.addView(mPreview);
layout.bringToFront();
scan.bringToFront();
search.bringToFront();
friendImport.bringToFront();
編集: これが私が話していることの例の画像です(私は画面全体を覆うように白い透明な画像を取得しようとしています):