|
31.如何對(duì)EditText進(jìn)行setText()的時(shí)候使其自動(dòng)換行
Java代碼
<EditText android:layout_width="200dp" android:layout_height="wrap_content"
android:id="@+id/input" android:singleLine="false"
/>
我們只要確保singleLine為false的話,并且設(shè)置寬度一定,就可以自動(dòng)換行,注意在這里不要設(shè)置
Java代碼
input.setInputType(0);
不然就不會(huì)自動(dòng)換行
2.在TableLayout中布局一行,設(shè)置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.如何設(shè)置EditText隱藏鍵盤(pán)
Java代碼
(EditText)mMarket.setInputType(0);
4.如何設(shè)置EditText不被輸入法遮蓋
Java代碼
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
上一篇: Android開(kāi)發(fā)指南1-框架主題-基礎(chǔ)知識(shí)下一篇: 介紹AsyncTask的用法用法
|