TextureView

不需要经过算法处理,底层API封装好了。

mTextureView = findViewById(R.id.surface_yuv);

mTextureView.setRotation(90); // 顺时针旋转90°

mTextureView.setRotationY(180); // 镜面对称

只是预览的处理,原始数据不变。

Android TextureView简易教程 - 泡在网上的日子

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将 TextureView 全屏,可以按照以下步骤进行操作: 1. 将 TextureView 添加到布局文件中,并设置其宽高。 ``` <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <TextureView android:id="@+id/texture_view" android:layout_width="match_parent" android:layout_height="match_parent" /> </FrameLayout> ``` 2. 在 Activity 的 onCreate 方法中获取 TextureView,并设置其监听器。 ``` private TextureView textureView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textureView = findViewById(R.id.texture_view); textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() { @Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { // TextureView 可用时,将其设置为全屏 textureView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) { // TextureView 大小变化时,重新设置布局参数 textureView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { return true; } @Override public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) { } }); } ``` 在 TextureView 的监听器中,通过设置布局参数,将 TextureView 设置为全屏。当 TextureView 的大小发生变化时,也需要重新设置布局参数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值