【问题标题】:Change android softkeyboard sample designs, button and background images更改 android 软键盘示例设计、按钮和背景图像
【发布时间】:2012-12-05 05:55:59
【问题描述】:

我正在通过修改 SDK 中的 android 软键盘示例来构建自定义键盘。我想更改按钮和背景的图像,但我无法弄清楚这些值的存储位置。它们存储在哪里,或者我如何更改图像或仅更改颜色?

【问题讨论】:

    标签: android


    【解决方案1】:

    在onClick方法中你需要改变按钮的图像,这样..

    public void onClick(View v) {
        if(v==buttonName){
            buttonName.setBackgroundResource(R.drawable.imageName);
        }       
    }
    

    可以在 input.xml 中使用android:background更改键盘背景颜色

    【讨论】:

    • 好的,但是如何在单击按钮之前更改按钮图像?默认
    • 我尝试为 input.xml 更改 android:background 并没有用
    【解决方案2】:

    您需要编辑文件res/xml/qwerty.xml

    您可以查看KeyboardKeys 的文档。最后一个定义了按键上显示的内容(但看起来您不能更改背景)。

    【讨论】:

      【解决方案3】:

      你需要编辑文件

      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 文档中可以找到更多属性。

      【讨论】:

        猜你喜欢
        • 2023-03-10
        • 2013-03-25
        • 2013-09-07
        • 2013-07-16
        • 2016-07-12
        • 2018-03-18
        • 2019-03-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多