- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在尝试将我的应用转换到 Chromecast。我开始在 https://developers.google.com/cast/docs/android_sender_integrate 之后添加一个按钮指导。
添加 MediaRouteButton 后,我得到:
Caused by: java.lang.IllegalArgumentException: background can not be translucent: #0
at android.support.v4.graphics.ColorUtils.calculateContrast(ColorUtils.java:93)
at android.support.v7.app.MediaRouterThemeHelper.getControllerColor(MediaRouterThemeHelper.java:88)
at android.support.v7.app.MediaRouterThemeHelper.getStyledRouterThemeId(MediaRouterThemeHelper.java:185)
at android.support.v7.app.MediaRouterThemeHelper.createThemedContext(MediaRouterThemeHelper.java:60)
at android.support.v7.app.MediaRouteButton.<init>(MediaRouteButton.java:124)
at android.support.v7.app.MediaRouteButton.<init>(MediaRouteButton.java:120)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:408)
at android.app.Activity.setContentView(Activity.java:2198)
我搜索了 SO,发现了另一个类似的问题,评论者要求将背景标记添加到 MediaRouteButton 的 xml 条目。这是我的布局 xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mdb_reader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/mdb_book_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.app.MediaRouteButton
android:id="@+id/media_route_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/black"
android:layout_weight="1"
android:mediaRouteTypes="user"
android:visibility="gone" />
</LinearLayout>
</FrameLayout>
(我嵌套了两个布局,因为它是以编程方式使用的,无论如何我已经尝试将 MediaRouteButton 移得更高但没有帮助)。
我还看到了一些关于主题的提示,这是我的 AndroidManifest.xml
application
条目:
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:background="@android:color/black"
android:theme="@style/AppTheme">
vales/styles.xml
<resources>
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="Theme.CastVideosTheme" parent="AppBaseTheme">
<item name="mediaRouteTheme">@style/CustomMediaRouterTheme</item>
</style>
<style name="CustomMediaRouterTheme" parent="Theme.MediaRouter">
<item name="mediaRouteButtonStyle">@style/CustomMediaRouteButtonStyle</item>
</style>
<style name="CustomMediaRouteButtonStyle" parent="Widget.MediaRouter.Light.MediaRouteButton">
<item name="buttonTint">@color/black</item>
</style>
</resources>
values-v11/styles.xml
<resources>
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
</style>
<style name="Theme.CastVideosTheme" parent="AppBaseTheme">
<item name="mediaRouteTheme">@style/CustomMediaRouterTheme</item>
</style>
<style name="CustomMediaRouterTheme" parent="Theme.MediaRouter">
<item name="mediaRouteButtonStyle">@style/CustomMediaRouteButtonStyle</item>
</style>
<style name="CustomMediaRouteButtonStyle" parent="Widget.MediaRouter.Light.MediaRouteButton">
<item name="buttonTint">@color/black</item>
</style>
</resources>
values-v14
<resources>
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
</style>
<style name="Theme.CastVideosTheme" parent="AppBaseTheme">
<item name="mediaRouteTheme">@style/CustomMediaRouterTheme</item>
</style>
<style name="CustomMediaRouterTheme" parent="Theme.MediaRouter">
<item name="mediaRouteButtonStyle">@style/CustomMediaRouteButtonStyle</item>
</style>
<style name="CustomMediaRouteButtonStyle" parent="Widget.MediaRouter.Light.MediaRouteButton">
<item name="buttonTint">@color/black</item>
</style>
</resources>
在我看来一切正常,但我仍然遇到该死的错误。
我正在使用 Android 26 进行构建。
最佳答案
如果您直接实例化 MediaRouteChooserDialog
(又名。为 chromecast 做更多的自定义实现),并且您不想使用 AppCompat 主题派生作为您的应用程序主题,您可以这样做:
MediaRouteChooserDialog builder = new MediaRouteChooserDialog(context, R.style.Theme_AppCompat_NoActionBar);
这会传入默认的 AppCompat.NoActionBar 主题供对话框使用。您可以传递任何您想要的主题,只要它是 AppCompat 的后代即可。
至少适用于 androidx、v7-28 和 v7-28 支持库。不确定旧版本。
关于android - 为什么我得到 java.lang.IllegalArgumentException : background can not be translucent: #0 when using MediaRouteButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46811254/
我正在开发在 Android Lollipop 上运行的应用程序。我已使用以下代码设置状态栏颜色。 首先我设置此标志WindowManager.LayoutParams.FLAG_DRAWS_SYST
下图基本上是我的目标,一个完全透明的导航栏(不是半透明的),它背后的内容不断获得插入更新,所以它在它后面绘制,但没有得到导航控件覆盖的任何 UI。 到目前为止,实现上图中结果的唯一方法是设置标志 FL
我创建了一种新样式来将背景设置为透明,但出于某种原因,因为当设备旋转时应用程序不会将布局更改为横向。 我应该在新样式中指定一些东西吗? 代码如下: @color/background 最佳
更新 2:我仍然希望在这个问题上得到一些帮助,所以既然我已经更好地缩小了范围,我将稍微完善我的问题。 我的 UIViewController 层次结构如下所示: 如果用户触摸过滤器图标并选择电梯类型,
我正在尝试为我的 Android 应用程序使用透明背景,如下所述: http://developer.android.com/training/basics/supporting-devices/pl
我想将支持操作栏添加到我的一项 Activity 中,我之前一直在使用 theme.translucent 进行此 Activity ,但为了使支持操作栏工作,我需要继承 Theme.AppCompa
当您尝试在 iPhone 的“便笺”应用程序中删除便笺时,会弹出 UIActionSheet。该片材是半透明的(但不是黑色半透明的)。这是如何实现的?是否可以将UIActionSheet的背景设置为某
我正在使用:android:theme="@android:style/Theme.Translucent.NoTitleBar" 结合:getWindow().setFlags(WindowMana
我无法禁用 QLPreviewController 的半透明属性。我已经尝试过: let preview = SideQLPreviewController() preview.navigatio
我有一个应用程序,其中包含一个父项和一些子项 Activity 。要求是在子 Activity 启动时播放一些自定义动画。为了流畅的动画并避免切换之间的延迟,我在 list 中的应用程序上应用了 Th
Android 上的 StatusBar 覆盖了我的应用程序的 header 。我所做的一切,我都无法做到不被覆盖。 我试过: 和 StatusBar.setTranslucent(false) 但
我正在开发一个 Android 项目,我在其中有一个登录页面,我想在其中添加用户名和密码字段。我的设计要求我以这种半透明的方式放置它们,并在里面放置图像。我可以为 EditText 更改什么以使其半透
有没有办法为整个应用程序禁用 UINavigationBar Translucency? 我知道使用 [self.navigationController.navigationBar setTrans
我使用 UITableView 实例作为我的 ViewController View 的 subview ,表格的内容高于屏幕,因此它是可滚动的。这是 AppDelegate 中的代码: - (BOO
先说说我的情况。我在我的 appDelegate 中设置了 UINavigationBar 颜色,例如: [[UINavigationBar appearance] setBarTintColor:[
我有一个加载 div,以加载符号作为背景图像。我希望加载符号完全不透明。但是,为了淡化正在加载的页面,我将背景图像设置为具有 80% 的不透明度。这在 Chrome 和 Firefox 中运行良好,但
我正在尝试创建一个全屏半透明叠加层,它会在单击 float 操作按钮时显示,类似于 Google Keep。 (请注意,它扩展到全屏,状态图标突出显示, float 操作按钮突出显示,叠加层的 z-i
我遇到了一个关于导航栏的奇怪问题。我在 UINavigationController 中有一个带有 UItableViewControllers 和 UIViewController 的应用程序。 应
在我的新 iOS 应用中,我想为整个应用及其 View 使用固定背景。 当单击导航项以显示设置表 Controller 时,一个丑陋的黑色半透明层或类似的东西会在几分之一秒内出现在整个屏幕上,直到动画
我在下面有这个圆柱体对象: glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cylinder_mat); cylinder(); 其中 static GL
我是一名优秀的程序员,十分优秀!