0

、これは私のコードです:カスタムキーボードのアトリビュートカラーを設定するには?私は、プロジェクト内の<strong>現在のテーマ</strong>に応じて自分の色を変更するには、私のカスタムキーボードを作るしようとしているが、それが失敗した

<?xml version="1.0" encoding="UTF-8"?> 
    <android.inputmethodservice.KeyboardView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/keyboard" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:keyBackground = "@drawable/keybackground" 
     android:keyTextColor="?attr/colorPrimary" 
     android:background="?attr/android:colorBackground" 
     android:keyTextSize="22sp"/> 

私は定期的に色を入れると、すべてが正常に動作します!私はそれをどのように柔軟にすることができますか?

+0

[Androidカスタムキーボードのさまざまな背景を設定する方法](https://stackoverflow.com/questions/18224520/how-to-set-different-background-of-keys-for-android-カスタムキーボード) –

+0

私のqoustionは全く違っています!重複としてマークする前にお読みください... – batsheva

答えて

0

私は、これはあなたが探しているものであるか分からないが、あなたはRES-自動名前空間を使用して試みることができる:

<android.inputmethodservice.KeyboardView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/keyboard" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    custom:keyBackground = "@drawable/keybackground" 
    custom:keyTextColor="?attr/colorPrimary" 
    android:background="?attr/android:colorBackground" 
    custom:keyTextSize="22sp"/> 

アプリの実行中に動的に変更することを探しているなら、私は思いますリンクされた答えが行く方法です。動的に変更すべき事項は、好ましくはコードで行い、静的設計は好ましくはXMLで行う。

関連する問題

 関連する問題