我开发了unity3d的android插件来播放视频,所以我使用TextureView来渲染视频。
一切运行良好,但当我想要设置我的TextureView对象的旋转到90,它将是不可见的,而另一个值,如30,60甚至89.92.
我不知道为什么会这样
这是我在创建TextureView对象时的代码。
Activity a = UnityPlayer.currentActivity;
mediaPlayerContainer = new TextureView(a);
RelativeLayout.LayoutParams l;
l = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
l.addRule(RelativeLayout.CENTER_IN_PARENT, -1);
mediaPlayerContainer.setLayoutParams(l);
mediaPlayerContainer.setRotation(89.92f);
mediaPlayerContainer.setFocusable( true );
mediaPlayerContainer.setFocusableInTouchMode( true );
mediaPlayerContainer.setVisibility(View.GONE);
mediaPlayerContainer.setSurfaceTextureListener(this);
layout.addView(mediaPlayerContainer, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
发布于 2017-05-16 16:07:52
因为轴心点不在TextureView的中心,而是在左上角。
你应该先做一点平移,做旋转,然后再平移回来。
例如:
mView.translate(-mView.getWidth()/2, -mView.getHeight()/2);
mView.setRotation(90);
mView.translate(mView.getWidth()/2, mView.getHeight()/2);
https://stackoverflow.com/questions/22473068
复制相似问题