0

次のように、テクスチャ マトリックスを設定して、カメラ プレビューを正方形にしました。

ここに画像の説明を入力

ただし、アクションバーのオーバーフロー ボタンまたは下部のボタンをクリックすると、カメラ プレビューの非表示部分が次のように表示されます。

ここに画像の説明を入力

私はこれについて何も知りません、誰かが私を助けてくれますか???

4

1 に答える 1

0

それは時々起こることです、理由はよくわかりませんが、簡単に防ぐことができます. あなたのレイアウトでは、次のようなものがある場合:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:background="@color/black" >


        <TextureView
            android:id="@+id/textureView"
            android:layout_width="YOUR_WIDTH"
            android:layout_height="YOUR_HEIGHT" >
        </TextureView>

        <!-- other stuff -->
  </LinearLayout>

次のように、テクスチャ ビューを同じサイズのフレーム レイアウトまたはその他のレイアウトでラップするだけです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:background="@color/black" >

    <FrameLayout
            android:layout_width="YOUR_WIDTH"
            android:layout_height="YOUR_HEIGHT" 
       android:background="@color/black" >


        <TextureView
            android:id="@+id/textureView"
            android:layout_width="YOUR_WIDTH"
            android:layout_height="YOUR_HEIGHT" >
        </TextureView>
    </FrameLayout>

        <!-- other stuff -->
  </LinearLayout>

実行時に の寸法TextureViewを変更する場合は、ラッパーの寸法もFrameLayoutまったく同じに変更することを忘れないでください。

于 2014-10-15T19:38:47.377 に答える