[英]How can I set transparency of MediaController background in android
try setting the background color with a transparent color instead of alpha. 尝试将背景颜色设置为透明颜色而不是Alpha。
For example, with color hex #99CC00: 例如,使用颜色十六进制#99CC00:
In your colors.xml : 在您的colors.xml中 :
<resources>
<color name="NoTransparent">#FF99CC00</color>
<color name="AlmostTransparent">#4499CC00</color>
<color name="FullTransparent">#0099CC00</color>
</resources>
Then in your activity: 然后在您的活动中:
mediaController.setBackgroundColor(getResources().getColor(R.color.AlmostTransparent));
Or in your layout file: 或在您的布局文件中:
<MediaController
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/media_controller"
android:background="@color/AlmostTransparent" />
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:
这不会对控件或其他MediaController视图产生影响:
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));
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.