0

次のカスタム属性を考慮して、カスタム テーマを作成しました。

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <attr name="GlideColour" format="color"/>
    <attr name="BackgroundColour" format="reference|color"/>
    <attr name="SuggestionColour" format="color"/>
    <attr name="KeyBackgroundColour" format="color"/>
    <attr name="KeyBorderColour" format="color"/>
    <attr name="SpaceBackgroundColour" format="color"/>
    <attr name="SpaceTextColour" format="color"/>
    <attr name="TextColour" format="color"/>
    <attr name="BackEnterColour" format="color"/>
    <attr name="PopUpDrawerColour" format="color"/>
    <attr name="DrawerSelectColour" format="color"/>
    <attr name="UtilityTextColour" format="color"/>
    <attr name="KeyboardBackground" format="reference"/>
    <attr name="KeyStyle" format="reference"/>
    <attr name="SpaceStyle" format="reference"/>
    <attr name="UtilityStyle" format="reference"/>
    <attr name="EnterStyle" format="reference"/>
    <attr name="BackStyle" format="reference"/>
    <attr name="KeyboardStyle" format="reference"/>
    <attr name="CapsStyle" format="reference"/>
    <attr name="DrawerButtonStyle" format="reference"/>
</resources>

私が作成したテーマは次のとおりです。

<style name="Standard" parent="Theme.AppCompat.Light.DarkActionBar">
         <item name="colorPrimary">@color/colorPrimary</item>
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
         <item name="colorAccent">@color/colorAccent</item>

         <item name="KeyboardBackground">@color/standard_background_color</item>
         <item name="GlideColour">@color/standard_glide_color</item>
         <item name="BackgroundColour">@color/standard_background_color</item>
         <item name="SuggestionColour">@color/standard_suggestion_color</item>
         <item name="SpaceBackgroundColour">@color/standard_space_background_color</item>
         <item name="SpaceTextColour">@color/standard_space_text_color</item>
         <item name="TextColour">@color/standard_text_color</item>
         <item name="BackEnterColour">@color/standard_back_space_color</item>
         <item name="UtilityTextColour">@color/standard_utility_color</item>
         <item name="KeyStyle">@style/standard_key_button</item>
         <item name="SpaceStyle">@style/standard_space_button</item>
         <item name="UtilityStyle">@style/standard_utility_style</item>
         <item name="EnterStyle">@style/standard_enter_style</item>
         <item name="BackStyle">@style/standard_back_style</item>
         <item name="KeyboardStyle">@style/standard_keyboard_style</item>
         <item name="CapsStyle">@style/standard_caps_style</item>
         <item name="DrawerButtonStyle">@style/standard_drawer_button_style</item>
     </style>

ただし、このテーマからカスタム スタイル属性を適用すると、ビューに追加されません。次に例を示します。

<com.nisarg.nboard.SwipeLayout android:layout_width="match_parent"
    android:layout_height="@dimen/keyboard_height"
    style="?KeyboardStyle"
    android:id="@+id/Rel"
    xmlns:android="http://schemas.android.com/apk/res/android">

私にこれを与えます: ここに画像の説明を入力

これを私に与えるべき場所:

ここに画像の説明を入力

つまり、参照されているスタイルが要素にまったく追加されていません。なぜこれが機能しないのかわかりません。ここで何が問題なのですか?

参考にしたスタイルはこちら

<style name="standard_keyboard_style" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:background">@color/standard_background_color</item>
    </style>

私が見つけた問題は参照にあり、「attr /」を使用できないか、そうしないとエラーがスローされます。

4

1 に答える 1