Android 样式未从theme.xml中定义的自定义属性设置

Android 样式未从theme.xml中定义的自定义属性设置,android,styling,android-custom-attributes,Android,Styling,Android Custom Attributes,我试图利用主题来创建一个夜间模式的主题。但是,样式设置似乎不正确 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"

我试图利用主题来创建一个夜间模式的主题。但是,样式设置似乎不正确

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:longClickable="false"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="?commentHeader">

attrs.xml

<declare-styleable name="AppTheme">
        <attr name="commentHeader" format="reference" />
</declare-styleable>
<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="commentHeader">@style/CommentHeaderLight</item>
</style>

theme.xml

<declare-styleable name="AppTheme">
        <attr name="commentHeader" format="reference" />
</declare-styleable>
<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="commentHeader">@style/CommentHeaderLight</item>
</style>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
真的
@风格/评论头灯
theme.xml:CommentHeaderLight

<style name="CommentHeaderLight">
    <item name="android:background">@drawable/comment_header_background</item>
    <item name="android:paddingLeft">16dp</item>
    <item name="android:paddingRight">16dp</item>
    <item name="android:paddingTop">8dp</item>
    <item name="android:paddingBottom">8dp</item>
</style>

@可绘制/注释\u标题\u背景
16dp
16dp
8dp
8dp
最终视图显示为股票背景,没有填充。我是否正确地解决了这个问题,或者是否有其他方法来解决这个问题