0

i had made camera preview to squared by setting Texture Matrix, like this:

enter image description here

but when click the overflow button of actionbar or the button in bottom, the hidden part of camera preview will be shown, like this:

enter image description here

I have no idea about this, could someone help me???

Carlos Robles
  • 10,828
  • 3
  • 41
  • 60
mayi
  • 1
  • 2

1 Answers1

0

That is something that sometimes happens, I dont really know why, but you can easily prevent it. In you layout, if you have something like:

<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>

Just wrap the texture view with a framelayout, or any other layout, with the same dimensions, something like this:

<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>

If you change the dimensions of the TextureViewin runtime, remember also to change the dimensions of the wrapper FrameLayoutto exactly the same

Carlos Robles
  • 10,828
  • 3
  • 41
  • 60