日期:2014-05-16 浏览次数:20430 次
在pjsip视频通信开发(上层应用)之EditText重写中我制作了一个显示输入内容的EditText,这里将制作一个数字键盘,其实跟计算器一样,最多的就是用TableLayout来实现,内部通过权重(weight)来实现布局的统一,上层实现按键事件触发回调实现内容的输出。
键盘布局:
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" > <ImageButton android:id="@+id/button1" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_one" android:src="@drawable/dial_num_1" /> <ImageButton android:id="@+id/button2" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_two" android:src="@drawable/dial_num_2" /> <ImageButton android:id="@+id/button3" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_three" android:src="@drawable/dial_num_3" /> </TableRow> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" > <ImageButton android:id="@+id/button4" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_four" android:src="@drawable/dial_num_4" /> <ImageButton android:id="@+id/button5" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_five" android:src="@drawable/dial_num_5" /> <ImageButton android:id="@+id/button6" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_six" android:src="@drawable/dial_num_6" /> </TableRow> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" > <ImageButton android:id="@+id/button7" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_seven" android:src="@drawable/dial_num_7" /> <ImageButton android:id="@+id/button8" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_eight" android:src="@drawable/dial_num_8" /> <ImageButton android:id="@+id/button9" style="@style/DialtactsDialpadButtonStyle" android:contentDescription="@string/description_image_button_nine" android:src="@drawable/dial_num_9" /> </TableRow> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"