2012-08-31 2 views
3

안드로이드 키보드 개발 : 어떻게 키 미리보기의 배경 이미지를 변경할 수 있습니까?Android 키보드 키 미리보기 배경 이미지

+0

이 게시물이 도움이 될 수 있습니다. http://stackoverflow.com/questions/2979926/android-how-to-create-custom-shape-keys-on-keyboard –

+0

대단히 감사합니다. 키 배경입니다. 주요 미리보기 배경을 변경하고 싶습니다. – Maxbuntu

답변

5

KeyboardView를 확장하여 사용자 정의 키보드를 만드는 경우 'android : keyPreviewLayout'attr을 사용하여 사용자 정의 KeyboardView에 사용자 정의 키 미리보기 레이아웃을 설정할 수 있습니다.

예.

<com.example.myApp.MyCustomKeyboardView 
     android:id="@+id/keyboard_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:keyPreviewLayout="@layout/my_custom_layout" /> 

my_custom_layout.xml이

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="80sp" 
    android:textSize="40sp" 
    android:textColor="?android:attr/textColorPrimaryInverse" 
    android:minWidth="32dip" 
    android:gravity="center" 
    android:background="@color/black"/> 

희망이 도움이 같은 사용자 정의 미리보기 레이아웃 뭔가

!

+1

감사합니다. evr, 그건 내가 원한 것에 매우 가깝습니다. 방금 색상을 이미지로 바꾸고 값을 필요로하지 않았습니다. android : background = "@ drawable/preview" – Maxbuntu

+1

내 키의 LongPress 이벤트에서 keyPreviewLayout을 변경하고 싶습니다. ?? –