Android手勢識別 Camera 預覽介面上顯示文字 佈局注意事項(merge佈局)
阿新 • • 發佈:2019-01-25
通常在Surfaceview作為預覽視訊幀的載體,有時需在上面顯示提示文字。以前我弄的都好好的,今天忽然發現疊加的TextView不管咋弄都出不來文字了,跟Surfaceview一起放在FrameLayout也不行,後來想到merge佈局,發現也不行。大爺的,奇了怪了,最後發現了原因,原來是順序問題。也即無論是在RelativeLayout裡還是merge佈局裡,View是逐個疊加上去的,一層一層鋪上去的。如果你先放TextView在最前面,那肯定被後面的全屏Surfaceview覆蓋了。用常規的RelativeLayout或者merge,只要處理好這個順序問題都可以實現效果。下面附上本文的佈局:
- <spanstyle="font-family:Comic Sans MS;font-size:18px;"><mergexmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
-
tools:context
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
- <SurfaceView
- android:id="@+id/previewSV"
- android:layout_width="0dip"
- android:layout_height="0dip"/>
-
</FrameLayout
- <TextView
- android:id="@+id/tv_info"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="開始檢測..."
- android:textColor="@android:color/holo_blue_light"
- android:textSize="25sp"
- android:visibility="visible"/>
- <org.yanzi.ui.HandView
- android:id="@+id/hand_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
- <ImageButton
- android:id="@+id/photoImgBtn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom|center_horizontal"
- android:background="@drawable/photo_img_btn"/>
- </merge></span>
傳兩張效果圖:
張開手,紅色畫框:
手指合攏,畫藍框: