【发布时间】:2012-12-05 05:55:59
【问题描述】:
我正在通过修改 SDK 中的 android 软键盘示例来构建自定义键盘。我想更改按钮和背景的图像,但我无法弄清楚这些值的存储位置。它们存储在哪里,或者我如何更改图像或仅更改颜色?
【问题讨论】:
标签: android
我正在通过修改 SDK 中的 android 软键盘示例来构建自定义键盘。我想更改按钮和背景的图像,但我无法弄清楚这些值的存储位置。它们存储在哪里,或者我如何更改图像或仅更改颜色?
【问题讨论】:
标签: android
在onClick方法中你需要改变按钮的图像,这样..
public void onClick(View v) {
if(v==buttonName){
buttonName.setBackgroundResource(R.drawable.imageName);
}
}
可以在 input.xml 中使用android:background更改键盘背景颜色
【讨论】:
你需要编辑文件
res/layout/input.xml
示例 input.xml 可能如下所示。
<com.example.keyboard.LatinKeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/keyboardbackground"
android:keyBackground="@drawable/samplekeybackground"
android:keyPreviewLayout="@layout/input_key_preview"
android:keyTextcolor="@android:color/black"/>
在KeyboardView 文档中可以找到更多属性。
【讨论】: