我们如何更改以Android画中画模式添加的可绘制对象的颜色

时间:2019-04-20 15:35:48

标签: android android-picture-in-picture

我在画中画模式下添加了一个可绘制的黑色复选图标。它是黑色的,并且在pip窗口中与其他默认pip图标(设置图标,十字图标)一样显示为白色。< / p>

我还尝试传递红色图标,并且它也变成了白色。

是否可以像实际显示那样在PIP窗口上显示图标?

以下是我添加的用于在“ PIP”窗口中添加图标的代码

internal fun updatePictureInPictureActions(
        @DrawableRes iconId: Int, title: String, controlType: Int, requestCode: Int) {
    val actions = ArrayList<RemoteAction>()

    // This is the PendingIntent that is invoked when a user clicks on the action item.
    // You need to use distinct request codes for play and pause, or the PendingIntent won't
    // be properly updated.
    val intent = PendingIntent.getBroadcast(
            this,
            requestCode,
            Intent(ACTION_MEDIA_CONTROL).putExtra(EXTRA_CONTROL_TYPE, controlType),
            0)
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        val icon = Icon.createWithResource(this, iconId)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            actions.add(RemoteAction(icon, title, title, intent))
            mPictureInPictureParamsBuilder.setActions(actions)
            setPictureInPictureParams(mPictureInPictureParamsBuilder.build())
            var result = enterPictureInPictureMode(mPictureInPictureParamsBuilder.build())
            Log.i(TAG, " result of enterPictureInPictureMode - " + result)
        }

    } else {
        TODO("VERSION.SDK_INT < M")
    }

}

screenshot

我已经添加了PIP窗口的屏幕快照以供参考。

0 个答案:

没有答案