本文介绍了如何在TextureView上添加视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的 TextureView 上添加 View ,以便在其中播放视频我以前使用过 VideoView ,这完全没问题,但是我在动画方面遇到了问题,因此我将其更改为 TextureView ,现在我不能放置任何 View 超过它!似乎 Textureview 将覆盖所有视图这是我的xml布局:

i need to add View over my TextureView which play video in iti used VideoView before and it was totally fine but i had problem with animation so i changed it to TextureView and now i can't put any View over it!seems that Textureview will cover over all viewsthis is my xml layout :

  <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/frmview"
    >

    <com.my.app.TextureVideoView
        android:id="@+id/vv_play"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:alpha="0.0" />

    <ImageView
        android:id="@+id/iv_play"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:srcCompat="@drawable/app_ic" />
</FrameLayout>

如何在正在播放视频的 TextureView 上放置 View ?

How can i put a View over TextureView which is playing video?

推荐答案

最后,在初始化 TextureView 并播放视频之后,我不得不以编程方式将其添加到我的 FrameLayout 中!>

finally i had to add it programmically to my FrameLayout after initializing TextureView and playing video!

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    mPreview = (TextureView) findViewById(R.id.vv_play);
    mPreview.setSurfaceTextureListener(this);
    FrameLayout frameLayout = (FrameLayout) findViewById(R.id.frmview);

    ImageView img = new ImageView(this);
    img.setImageResource(R.drawable.app_ic);
    frameLayout.addView(img);
}

这篇关于如何在TextureView上添加视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-11 22:37