Android 自定义 省份、车牌号键盘。

本文介绍如何在Android应用中自定义一个包含省份和车牌号的键盘。通过创建XML数据源`number_or_letters.xml`来配置省份数据,并在drawable目录下定义按键背景资源`click_key_bg.xml`,实现键盘界面的关键部分。
摘要由CSDN通过智能技术生成


1.配省份、车牌号kebord数据源。

首先在资源目录res文件夹下创建xml文件夹。

明明省份数据源:

number_or_letters.xml:

<?xml version="1.0" encoding="utf-8"?>
<Keyboard android:keyWidth="10%p" android:keyHeight="8%"  
        android:horizontalGap="0.0px" android:verticalGap="0.0px"  
        xmlns:android="http://schemas.android.com/apk/res/android">  
        
    <Row android:verticalGap="1%p">
      <Key android:codes="49" android:keyLabel="1"
           android:horizontalGap="1%p" android:keyWidth="8%p" 
           android:keyEdgeFlags="left"  />
      <Key android:codes="50" android:keyLabel="2"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="51" android:keyLabel="3"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="52" android:keyLabel="4"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="53" android:keyLabel="5"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="54" android:keyLabel="6"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="55" android:keyLabel="7"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="56" android:keyLabel="8"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="57" android:keyLabel="9"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="48" android:keyLabel="0" 
           android:horizontalGap="2%p" android:keyWidth="8%p"
           android:keyEdgeFlags="right"/>
   </Row>
   
   <Row android:verticalGap="1%p">
      <Key android:codes="81" android:keyLabel="Q"
           android:horizontalGap="1%p" android:keyWidth="8%p"
           android:keyEdgeFlags="left" />
      <Key android:codes="87" android:keyLabel="W"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="69" android:keyLabel="E"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="82" android:keyLabel="R"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="84" android:keyLabel="T"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="89" android:keyLabel="Y"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="85" android:keyLabel="U"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="73" android:keyLabel="I"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="79" android:keyLabel="O"
           android:horizontalGap="2%p" android:keyWidth="8%p" />
      <Key android:codes="80" android:keyLabel="P" 
           android:horizontalGap="2%p" android
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值