android:textColorHint="#ffff00"
设置提示信息文字的颜色,默认为灰色
android:textScaleX="1.5"
控制字与字之间的间距
android:typeface="monospace"
字型,normal, sans, serif, monospace
android:background="@null"
空间背景,这里没有,指透明
android:layout_weight="1"
权重,控制控件之间的地位,在控制控件显示的大小时蛮有用的。
android:textAppearance="?android:attr/textAppearanceLargeInverse"
EditText始终不弹出软件键盘
1.EditText默认不弹出软件键盘
方法一:
在 AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden
java代码:
方法二: 让 EditText失去焦点,使用EditText的clearFocus方法
例如:EditText edit=(EditText)findViewById(R.id.edit);
edit.clearFocus();
方法三:
强制隐藏Android输入法窗口
例如:EditText edit=(EditText)findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);
二:如何对EditText进行setText()的时候使其自动换行
Java代码
<EditText android:layout_width="200dp" android:layout_height="wrap_content"
android:id="@+id/input" android:singleLine="false"
/>
我们只要确保singleLine为false的话,并且设置宽度一定,就可以自动换行,注意在这里不要设置
Java代码
input.setInputType(0);
不然就不会自动换行
2.在TableLayout中布局一行,设置EditText的xml属性:
Java代码
<!-- android:shrinkColumns="1" shrinks the 2nd column to fit the window -->
<!-- android:stretchColumns="1" stretches the 2nd column -->
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:paddingLeft="5dp"
android:paddingRight="5dp" android:stretchColumns="1">
<TableRow android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Email"
android:paddingRight="5dp">
</TextView>
<EditText android:id="@+id/txtEmail" android:layout_width="200dp"
android:layout_height="wrap_content" android:textSize="18sp"
android:singleLine="false" android:inputType="textEmailAddress">
</EditText>
</TableRow>
</TableLayout>
3.如何设置EditText隐藏键盘
Java代码
(EditText)mMarket.setInputType(0);
4.如何设置EditText不被输入法遮盖
Java代码
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
设置提示信息文字的颜色,默认为灰色
android:textScaleX="1.5"
控制字与字之间的间距
android:typeface="monospace"
字型,normal, sans, serif, monospace
android:background="@null"
空间背景,这里没有,指透明
android:layout_weight="1"
权重,控制控件之间的地位,在控制控件显示的大小时蛮有用的。
android:textAppearance="?android:attr/textAppearanceLargeInverse"
EditText始终不弹出软件键盘
1.EditText默认不弹出软件键盘
方法一:
在 AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden
java代码:
方法二: 让 EditText失去焦点,使用EditText的clearFocus方法
例如:EditText edit=(EditText)findViewById(R.id.edit);
edit.clearFocus();
方法三:
强制隐藏Android输入法窗口
例如:EditText edit=(EditText)findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);
二:如何对EditText进行setText()的时候使其自动换行
Java代码
<EditText android:layout_width="200dp" android:layout_height="wrap_content"
android:id="@+id/input" android:singleLine="false"
/>
我们只要确保singleLine为false的话,并且设置宽度一定,就可以自动换行,注意在这里不要设置
Java代码
input.setInputType(0);
不然就不会自动换行
2.在TableLayout中布局一行,设置EditText的xml属性:
Java代码
<!-- android:shrinkColumns="1" shrinks the 2nd column to fit the window -->
<!-- android:stretchColumns="1" stretches the 2nd column -->
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:paddingLeft="5dp"
android:paddingRight="5dp" android:stretchColumns="1">
<TableRow android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Email"
android:paddingRight="5dp">
</TextView>
<EditText android:id="@+id/txtEmail" android:layout_width="200dp"
android:layout_height="wrap_content" android:textSize="18sp"
android:singleLine="false" android:inputType="textEmailAddress">
</EditText>
</TableRow>
</TableLayout>
3.如何设置EditText隐藏键盘
Java代码
(EditText)mMarket.setInputType(0);
4.如何设置EditText不被输入法遮盖
Java代码
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);