安卓:如何禁止应用主题被应用到特定视图?

问题描述 投票:0回答:1

我的片段XML中定义了一个第三方视频播放器视图。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true"
        android:focusable="true"
        android:orientation="vertical">

    <com.3rdPartyView
            android:id="@+id/videoPlayerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
</LinearLayout>

视图的背景被我的主题覆盖,结果隐藏了正在播放的视频。我似乎不能让视图的背景不被我的主题设置。

我试过在视图本身以及它的外部线性布局上设置以下内容。

app:theme="@android:style/Theme.Holo.Light"
android:theme="@android:style/Theme.Holo.Light"
android:background="@null"

我也试过在碎片膨胀后手动添加视图 但不成功: 视图的背景被改变了。

我确定是这样的,因为我在主主题的attr.定义中注释了它,并且能够看到它的背景被改变。android:background 在其定义中,能够看到视频。

android android-theme
1个回答
0
投票

一个可以硬编码的主题在一个视图上。

<View ...
  android:theme="@style/ThemeOverlay.MaterialComponents.Dark"/>

我使用的那个第三方视图可能没有写好。

© www.soinside.com 2019 - 2024. All rights reserved.