【发布时间】:2017-08-04 13:10:56
【问题描述】:
默认 inputType 可以正常工作,但对于数字,屏幕不会调整大小。
我在清单文件中使用android:windowSoftInputMode="adjustResize" 进行活动。
我在表单底部有“邮件 ID”和“手机号”字段。像这样
它适用于邮件 ID..
但对于手机号码,这是号码字段..
这是我的 xml 文件的一部分...手机号是 editTest 字段,最后一个 inputType 编号。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white_smoke"
android:orientation="vertical"
android:paddingBottom="8dp">
<LinearLayout
style="@style/FormItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/TextFormLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name*" />
<EditText
android:id="@+id/edt_f_name"
style="@style/EditTextBgStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:inputType="textCapWords|textNoSuggestions" />
</LinearLayout>
.
.
.
.
other view
.
.
<LinearLayout
style="@style/FormItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<CheckBox
android:id="@+id/check_adds_same_as_per"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Same as Permanent Address" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/TextFormLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Communication Address*" />
<EditText
android:id="@+id/edt_commun_adds"
style="@style/EditTextBgStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:gravity="top"
android:lines="3"
android:maxLines="4"
android:inputType="textMultiLine|textNoSuggestions" />
</LinearLayout>
</LinearLayout>
<LinearLayout
style="@style/FormItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/TextFormLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mail ID" />
<EditText
android:id="@+id/edt_mail_id"
style="@style/EditTextBgStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5" />
</LinearLayout>
<LinearLayout
style="@style/FormItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/TextFormLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mobile No*" />
<EditText
android:id="@+id/edt_mobile_no"
style="@style/EditTextBgStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:inputType="number"
android:maxLength="10" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<include layout="@layout/master_button" />
</LinearLayout>
【问题讨论】:
-
尝试使用android:windowSoftInputMode="adjustSpan"
-
你的意思是“adjustPan”对吗?我也试过了..它不起作用。
-
尝试使用滚动视图放置布局
-
它只在滚动视图中。
-
scrollView 有 fillviewport = true 吗?
标签: android android-edittext android-keypad android-inputtype