本文介绍了如何在Android中设置MediaController背景的透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置MediaController背景而不是控件的透明度.

I want to set the transparency of MediaController background and not controls.

我尝试使用mediaController.setAlpha(0.6f),但它正在向控件应用透明度,例如

I tried using mediaController.setAlpha(0.6f), but it is applying transparency to controls as well like this

推荐答案

找到了一个棘手的解决方案,对我有用.想法是仅针对特定的背景布局将背景颜色设置为所需的透明度.这不会影响控件或其他MediaController视图:

Found a tricky solution, that worked for me. The idea is to set background color with desired transparency level only for the specific background layout. This will not have an impact on controls or other MediaController views:

videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            public void onPrepared(MediaPlayer mediaPlayer) {
                // get media controller background layout
                LinearLayout viewGroupLevel1 = (LinearLayout)  mediaController.getChildAt(0);
                //Set your color with desired transparency here:
                viewGroupLevel1.setBackgroundColor(getResources().getColor(R.color.transparent));
            }
        });

这篇关于如何在Android中设置MediaController背景的透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 20:02