editText属性

来源:互联网 发布:沪江网络课程 编辑:程序博客网 时间:2024/06/01 20:42

<EditText    android:layout_width="0dp"    android:layout_weight="2"    android:layout_height="match_parent"    android:layout_marginLeft="10dp"    android:layout_marginRight="15dp"    android:background="@null"  //背景设置null,不会加载别的不认识的背景,比如系统自带    android:gravity="center_vertical"    android:hint="请输入姓名"    android:imeOptions="actionSearch"    android:singleLine="true"    android:text="@={searchActivity.searchKey}"//要慎重使用,如果你没有使用databinding 的话,就删掉这一行    android:textColor="@color/colorTextcolor"    android:textColorHint="@color/colorOrderText"//hint 字体的颜色    android:textSize="20sp"    />

android:text="@={searchActivity.searchKey}"
在Databinding时使用,如果searchActivity.searchKey  返回一个String类型的字符串,就可以用这个方法来接收,而且不用再监听.


在弹出虚拟键盘的时候,弹出数字的虚拟键盘:

   android:digits="1234567890."//xml布局文件中,editText的属性


   editText.setInputType(EditorInfo.TYPE_CLASS_PHONE);  //再调用的时候,代码中添加

或者直接在属性中添加:


android:inputType="number"







原创粉丝点击