如何为IME设置背景图片?

问题描述:

我想知道如何在按键后面显示图像。我已经尝试过这样的:如何为IME设置背景图片?

<ImageView android:id="@+id/imageView1" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="50px" 
    android:padding="12dip" 
    android:background="#FFFFFF"> 
</ImageView> 

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android" 
    android:keyWidth="10%p" 
    android:horizontalGap="0px" 
    android:verticalGap="0px" 
    android:keyHeight="50%p" > 

    <Row> 
     <Key android:codes="113" 
      android:keyEdgeFlags="left" /> 
    </Row> 

</Keyboard> 

我知道,有一些基本的东西,缺少像钥匙(和至少其他25项)的形象,但我只是想告诉你一个例子。

TL; DR(虽然这不是一个很长的帖子):我想要在背景中有一个图像,并在前台有一个通常的键盘。

感谢提前:)

更新:我现在尝试这样做:

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android" 
    android:keyWidth="1%p" 
    android:horizontalGap="20px" 
    android:verticalGap="300px" 
    android:keyHeight="1%p" 
    android:background="@drawable/example" 
    > 

    <Row> 
     <Key android:codes="113" 
      android:keyEdgeFlags="left"></Key> 
     <Key android:codes="113" 
      android:keyEdgeFlags="left"></Key> 

    </Row> 
    <Row> 
     <Key android:codes="113" 
      android:keyEdgeFlags="left"></Key> 
     <Key android:codes="113" 
      android:keyEdgeFlags="left"></Key> 
    </Row> 

</Keyboard> 

没有工作:(XML是正确设置,因为它显示了某种键盘的,但背景是只是黑色的。

可以使用KeyboardView对象。它扩展View,所以你可以使用常规的android:background属性做你以后,然后附上KeyboardsetKeyboard()

+0

谢谢,我会试试看,如果不行的话会回来的:)不幸的是,我不能upvote你的评论:/ – 2013-03-07 19:13:51

+0

我编辑它与我试过。没有工作:( – 2013-03-07 19:24:50

+0

好吧,你并没有真正尝试我所说的,你根本没有使用'KeyboardView'对象,只是'Keyboard'。你读过[开发者指南创建输入法](http://developer.android.com/guide/topics/text/creating-input-method.html)呢?如果没有,你应该。 – Geobits 2013-03-07 20:06:18