Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓&x27;s TextureView设置旋转问题_Android_Unity3d_Textureview - Fatal编程技术网

Android 安卓&x27;s TextureView设置旋转问题

Android 安卓&x27;s TextureView设置旋转问题,android,unity3d,textureview,Android,Unity3d,Textureview,我开发了Unity3d的android插件来播放视频,所以我使用TextureView来渲染视频 一切正常,但当我想将TextureView对象的旋转设置为90时,它将不可见,而另一个值(如30、60甚至89.92)则有效 我不知道为什么会这样 这是我创建TextureView对象时的代码 Activity a = UnityPlayer.currentActivity; mediaPlayerContainer = new TextureView(a); Relativ

我开发了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));

因为轴心点不在TextureView的中心,而是在左上角

你应该先平移一点,做旋转,然后再平移回来

例如:

mView.translate(-mView.getWidth()/2, -mView.getHeight()/2);
mView.setRotation(90);
mView.translate(mView.getWidth()/2, mView.getHeight()/2);

使用setRotation(89.92)时,您会看到什么?@psk将MediaPlayer对象加载的视频,然后media player将表面设置为聚集在onSurfaceTextureAvailable事件中的表面。使用setRotation(89.92)时,视图是否旋转?你看到了什么?还有。当您调用setRotation(90)时,它没有被旋转?在我的代码中初始化一个TextureView之后,它是mediaPlayerContainer.setRotation(89.92f)。