Android 连接时不同的chromecast操作栏图标
我已经在我的应用程序中集成了chromecast。当chromecast连接和未连接时,我需要不同的操作栏图标。我创建了一个可绘制的Android 连接时不同的chromecast操作栏图标,android,chromecast,google-cast,Android,Chromecast,Google Cast,我已经在我的应用程序中集成了chromecast。当chromecast连接和未连接时,我需要不同的操作栏图标。我创建了一个可绘制的mr_ic\u media\u route\u holo\u light.xml,并在未连接时为chromecast图标添加了以下代码。但是,当连接不同的chromecast图标时,我需要添加什么?我尝试了创建xml-'ic\u media\u route\u connecting\u holo\u light.xml和mr\u ic\u media\u route
mr_ic\u media\u route\u holo\u light.xml
,并在未连接时为chromecast图标添加了以下代码。但是,当连接不同的chromecast图标时,我需要添加什么?我尝试了创建xml-'ic\u media\u route\u connecting\u holo\u light.xml
和mr\u ic\u media\u route\u connecting\u holo\u light.xml
用于在连接chromecast时显示图标,但不起作用。在连接chromecast或未连接chromecast时显示相同的图标。我正在使用themetheme.AppCompat.light
`
mr_ic_media_route_holo_light
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="@drawable/ic_cast_white_24dp"
android:duration="500"/>
<item
android:drawable="@drawable/ic_cast_white_24dp"
android:duration="500"/>
<item
android:drawable="@drawable/ic_cast_white_24dp"
android:duration="500"/>
<item
android:drawable="@drawable/ic_cast_white_24dp"
android:duration="500"/>
</animation-list>
您需要在绘图表中包含另一个xml,并将其命名为mr_ic_media_route_holo_light.xml。其默认内容为:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_enabled="true"
android:drawable="@drawable/mr_ic_media_route_on_holo_light" />
<item android:state_checkable="true" android:state_enabled="true"
android:drawable="@drawable/mr_ic_media_route_connecting_holo_light" />
<item android:state_enabled="true"
android:drawable="@drawable/mr_ic_media_route_off_holo_light" />
<item android:drawable="@drawable/mr_ic_media_route_disabled_holo_light" />
</selector>
并将其内容更新为您想要的内容。请注意,此文件的默认版本(以及引用的绘图表)可以在您的
/extras/android/support/v7/mediawrouter/res/drawable
中找到,但我所写的xml具有相同的名称-mr_ic_media_route_holo_light..请查看问题..您想让我删除我所写的xml,并使用根元素选择器和上面的创建另一个xml吗格式?mr_ic_media_route_holo_light.xml的内容应该与我提到的内容类似。然后您可以创建一个mr_ic_media_route_connecting_holo_light.xml来指出“连接”状态应该是什么,并可以将mr_ic_media_route_on_holo_light.png、mr_ic_media_route_off_holo_light.png和mr_ic_media_route_disabled_holo_light.png更新为您喜欢的任何内容。基本上,第一个xml文件包含对图标所有状态的引用,包括图标处于打开/关闭/禁用状态和连接状态,然后您可以更改每个引用指向的对象。