Я добавил значок проверки черного цвета, который можно нарисовать в моем режиме «картинка в картинке». Он черного цвета, а в окне пипа отображается белым цветом, как и другие значки пипса по умолчанию (значок настройки, значок крестика).
Я также пытался передать значок красного цвета, и он также становится белым.
Можно ли отобразить значок в окне 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")
}
}
Я добавил скриншот окна PIP для справки.