这是我的两个EditText用户名和密码,我使用的是TextInputLayout
<LinearLayout
android:id="@+id/linear2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/linear1"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/tplUserName"
style="@style/EditText_Style_1"
app:hintTextAppearance="@style/TextLabel">
<EditText
android:id="@+id/etUserName"
style="@style/StandardEditTextStyle"
android:hint="@string/un_login"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/tplPassword"
style="@style/EditText_Style_1"
app:hintTextAppearance="@style/TextLabel"
android:hint="@string/pass_login">
<EditText
android:id="@+id/etPassword"
style="@style/EditText_Style_For_All"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
这是我的style,EditText_Style_1
用于TextInputLayout和EditText_Style_For_All用于EditText.I set&#34; maxLines&#34;属性为两种样式但是当我按下&#34更改下一个EditText(密码)时;输入&#34;从Android键盘,它没有工作。我设置singleLine,我为我工作。你知道这个属性已被弃用。
<style name="EditText_Style_1">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColorHint">@color/textColor</item>
<item name="android:layout_marginRight">@dimen/reg_margin_right</item>
<item name="android:layout_marginLeft">@dimen/reg_margin_left</item>
<item name="android:fontFamily">sans-serif-thin</item>
<item name="android:maxLines">1</item>
</style>
<style name="EditText_Style_For_All">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/edit_text_color</item>
<item name="android:backgroundTint">@color/et_underline_color</item>
<item name="android:fontFamily">sans-serif-thin</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">15sp</item>
<item name="android:maxLines">1</item>
</style>
答案 0 :(得分:2)
尝试此设置 android:imeOptions="actionNext"
并设置 android:inputType="text"
到您的 EditText
示例代码
<android.support.design.widget.TextInputLayout
android:id="@+id/tplUserName"
style="@style/EditText_Style_1"
app:hintTextAppearance="@style/TextLabel">
<EditText
android:id="@+id/etUserName"
style="@style/StandardEditTextStyle"
android:imeOptions="actionNext"
android:inputType="text"
android:hint="@string/un_login"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/tplPassword"
style="@style/EditText_Style_1"
app:hintTextAppearance="@style/TextLabel"
android:hint="@string/pass_login">
<EditText
android:id="@+id/etPassword"
android:imeOptions="actionNext"
android:inputType="textPassword"
style="@style/EditText_Style_For_All"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
答案 1 :(得分:0)
也添加<item name="android:inputType">text</item>
。没有inputType
答案 2 :(得分:0)
<EditText
android:id="@+id/etUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="5"
style="@style/StandardEditTextStyle"
android:hint="@string/un_login"
/>
您只需要确保设置了“inputType”属性。没有这条线就行不了。
android:inputType="text"