【问题标题】:Android: Cast MiniControllerFragment customizationAndroid: Cast MiniControllerFragment 自定义
【发布时间】:2017-04-03 23:09:49
【问题描述】:

我正在尝试自定义 castBackground 和 castProgressBarColor MiniControllerFragment 属性,如官方文档中所述: https://developers.google.com/cast/docs/android_sender_advanced

我的 Activity 使用以下样式:

 <style name="AppTheme.NoActionBarNoTitle" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="castIntroOverlayStyle">@style/CustomCastIntroOverlay</item>
    <item name="castMiniControllerStyle">@style/CustomCastMiniController</item>
</style>

这是 CustomCastMiniController 样式:

   <style name="CustomCastMiniController" parent="CastMiniController">
    <item name="castShowImageThumbnail">true</item>
    <item name="castTitleTextAppearance">@style/TextAppearance.AppCompat.Subhead</item>
    <item name="castSubtitleTextAppearance">@style/TextAppearance.AppCompat.Caption</item>
    <item name="castBackground">#FFFFFF</item>
    <item name="castProgressBarColor">#FFFFFF</item>
</style>

我无法构建,因为这些错误:

Error:(2073, 21) No resource found that matches the given name: attr 'castBackground'.
Error:(2074, 21) No resource found that matches the given name: attr 'castProgressBarColor'.

如果我在我的 CustomCastMiniController 样式应用程序中删除这两个属性成功启动。

【问题讨论】:

    标签: android casting chromecast google-cast


    【解决方案1】:

    您应该始终检查最常用的version。在某些情况下,需要使用最新版本,因为某些功能尚未在旧版本中实现。您必须打开android-support-v7-appcompatproject.properties 文件并将目标更改为最新的version。之后,清理并构建您的项目。

    【讨论】:

      【解决方案2】:

      castBackgroundcastProgressBarColor 属性是在更高版本的 Google Cast SDK 中引入的,如release notes 所示:

      2016 年 10 月 24 日

      • 增加了自定义迷你控制器样式的功能:添加了castBackground 用于设置其背景颜色,castButtonColor 为迷你控制器中使用的所有按钮着色,castProgressBarColor 为进度条着色。

      因此,请确保您在 build.gradle 文件中使用最新版本的 Google Cast SDK 进行编译(撰写本文时版本为 10.0.0):

      dependencies {
          compile 'com.android.support:appcompat-v7:25.0.1'
          compile 'com.android.support:mediarouter-v7:25.0.1'
          compile 'com.google.android.gms:play-services-cast-framework:10.0.0'
      }
      

      【讨论】:

        【解决方案3】:

        如果今天有人仍然面临同样的问题,在我的情况下,问题要简单一点:

          Originally I was declaring:
          <fragment
                android:id="@+id/castMiniController"
                class="....MiniControllerFragment"
                 app:castBackground="#ffffff"
        

        这导致背景透明,而不是这样做:

               <fragment
                android:id="@+id/castMiniController"
                class="....MiniControllerFragment"
                app:castBackground="@color/saved_color"
        

        允许您有效地设置当前颜色。希望对你有帮助。

        【讨论】:

          【解决方案4】:

          在您的colors.xml 中定义颜色并在styles.xml 中将其定义为#000000 的@color/black 实例

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2019-10-08
            • 2019-08-12
            • 1970-01-01
            • 1970-01-01
            • 2016-11-03
            • 2019-03-09
            • 2021-08-22
            • 2015-08-17
            相关资源
            最近更新 更多