Android手势识别 Camera 预览界面上显示文字 布局注意事项(merge布局)

通常在Surfaceview作为预览视频帧的载体,有时需在上面显示提示文字。以前我弄的都好好的,今天忽然发现叠加的TextView不管咋弄都出不来文字了,跟Surfaceview一起放在FrameLayout也不行,后来想到merge布局,发现也不行。大爷的,奇了怪了,最后发现了原因,原来是顺序问题。也即无论是在RelativeLayout里还是merge布局里,View是逐个叠加上去的,一层一层铺上去的。如果你先放TextView在最前面,那肯定被后面的全屏Surfaceview覆盖了。用常规的RelativeLayout或者merge,只要处理好这个顺序问题都可以实现效果。下面附上本文的布局:

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. <span style="font-family:Comic Sans MS;font-size:18px;"><merge xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     tools:context=".CameraActivity" >  
  6.   
  7.     <FrameLayout  
  8.         android:layout_width="wrap_content"  
  9.         android:layout_height="wrap_content" >  
  10.   
  11.         <SurfaceView  
  12.             android:id="@+id/previewSV"  
  13.             android:layout_width="0dip"  
  14.             android:layout_height="0dip" />  
  15.     </FrameLayout>  
  16.   
  17.     <TextView  
  18.         android:id="@+id/tv_info"  
  19.         android:layout_width="match_parent"  
  20.         android:layout_height="wrap_content"  
  21.         android:text="开始检测..."  
  22.         android:textColor="@android:color/holo_blue_light"  
  23.         android:textSize="25sp"  
  24.         android:visibility="visible" />  
  25.   
  26.     <org.yanzi.ui.HandView  
  27.         android:id="@+id/hand_view"  
  28.         android:layout_width="match_parent"  
  29.         android:layout_height="match_parent" />  
  30.   
  31.     <ImageButton  
  32.         android:id="@+id/photoImgBtn"  
  33.         android:layout_width="wrap_content"  
  34.         android:layout_height="wrap_content"  
  35.         android:layout_gravity="bottom|center_horizontal"  
  36.         android:background="@drawable/photo_img_btn" />  
  37.   
  38. </merge></span>  

传两张效果图:

张开手,红色画框:



手指合拢,画蓝框:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值