마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 커스텀 키보드에서 키보드마다 개별 이미지 배경 지정이 가능한가요?

0 추천

커스텀 키보드를 만드는 중입니다.

현재 전체 키보드가 같은 레이아웃으로 같은이미지 배경만 쓰고있는데 개별로 지정하는 방법을 알고 싶습니다..

 

 

keyboard.xml을 만들어서 전체 레이아웃을 잡고

<com.abc.minikeyboard.MiniKeyboardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/keyboard"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:keyBackground="@drawable/change_image"
    android:keyTextColor="#000"
    android:layout_gravity="center"
    android:layout_centerHorizontal="true"
    android:background="@mipmap/backgorund"
    />

Service에서 이런식으로 코드를넣어 만들었습니다.

    @Override
    public void onInitializeInterface(){
        if(mEnglish != null){
            int displayWidth = getMaxWidth();
            if(displayWidth == mLastDisplayWidth) return;
            mLastDisplayWidth = displayWidth;
        }
        mEnglish = new MiniKeyboard(this, R.xml.english);
        mNumber = new MiniKeyboard(this, R.xml.number);
        mSymbol = new MiniKeyboard(this, R.xml.symbol);
    }
 

english.xml

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyHeight="10%p"
    android:keyWidth="16.66%p"
    android:keyBackground="@mipmap/ic_launcher"
    >

    <Row android:keyBackground="@mipmap/ic_launcher">
        <Key android:codes="97" android:keyIcon="@drawable/change_image"  android:keyEdgeFlags="left" />
        <Key android:codes="98"  android:keyLabel="b" />
        <Key android:codes="99" android:keyLabel="c" android:horizontalGap = "5%p" />
        <Key android:codes="100" android:keyLabel="d" />
        <Key android:codes="101" android:keyLabel="e" />
        <Key android:codes="103" android:keyLabel="g" android:keyEdgeFlags="right" />
    </Row>

...

 

헌대 키보드마다 다른 키보드 배경을 넣고싶은데 방법을 찾기가 힘드네요

<Row> 안의 <key>에 배경을 줘도 들어가지않고

 

참조할 만한 사이트나 고수분들의 조언 부탁드립니다.

 

 

R0R0 (2,610 포인트) 님이 2017년 7월 7일 질문
R0R0님이 2017년 7월 10일 수정

1개의 답변

0 추천
keyboardview 에서 그리셔야합니다.
익명사용자 님이 2017년 7월 26일 답변
...