[英]Squared Camera Preview Using TextureView
我已經通過設置“紋理矩陣”使攝像機預覽變為正方形,如下所示:
但是當單擊操作欄的溢出按鈕或底部的按鈕時,將顯示攝像機預覽的隱藏部分,如下所示:
我對此一無所知,有人可以幫我嗎???
有時會發生這種情況,我真的不知道為什么,但是您可以輕松地防止它發生。 在布局中,如果您有類似以下內容:
<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
的尺寸更改為完全相同
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.