我在Android中有一个带有GothicRegular字体的自定义editext,如下所示:
public class EditText_GothicRegular extends android.support.v7.widget.AppCompatEditText {
public EditText_GothicRegular(Context context) {
super(context);
disableCopyPaste();
}
public EditText_GothicRegular(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
disableCopyPaste();
}
public EditText_GothicRegular(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
disableCopyPaste();
}
private void disableCopyPaste() {
setTypeface(Fonts.gothic_regular);
}
}
我在设计中实现了这样的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:weightSum="1"
>
<com.app.quizjeetho.Fonts.Gothic_Bold
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_gravity="center"
android:layout_marginTop="@dimen/padding5"
android:layout_weight="0.1"
android:gravity="bottom"
android:text="@string/registertitle_txt"
android:textSize="@dimen/text20" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="0.60"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.3"
android:gravity="center"
android:weightSum="1">
<com.app.quizjeetho.Fonts.EditText_GothicRegular
android:id="@+id/fullname"
style="@style/Edittext"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:drawableLeft="@drawable/name_icon"
android:hint="@string/fullname_txt"
android:imeOptions="actionNext|flagNoExtractUi"
android:inputType="textNoSuggestions|text"
android:nextFocusRight="@+id/mobileno"
android:maxLength="50"
android:text=""
android:maxLines="1"/>
<View
android:layout_width="0dip"
android:layout_height="0dp"
android:layout_weight="0.1" />
<com.app.quizjeetho.Fonts.EditText_GothicRegular
android:id="@+id/mobileno"
style="@style/Edittext"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:drawableLeft="@drawable/mobile_icon"
android:hint="@string/mobileno_txt"
android:imeOptions="actionNext|flagNoExtractUi"
android:inputType="textNoSuggestions|number"
android:nextFocusDown="@+id/password"
android:maxLength="10"
android:maxLines="1"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.3"
android:gravity="center"
android:weightSum="1">
<com.app.quizjeetho.Fonts.EditText_GothicRegular
android:id="@+id/password"
style="@style/Edittext"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:drawableLeft="@drawable/password_icon"
android:hint="@string/password_txt"
android:imeOptions="actionDone|flagNoExtractUi"
android:inputType="textNoSuggestions|textPassword"
android:maxLength="50"
android:text=""
android:maxLines="1"/>
<View
android:layout_width="0dip"
android:layout_height="0dp"
android:layout_weight="0.1" />
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:orientation="vertical">
<com.app.quizjeetho.Fonts.EditText_GothicRegular
android:id="@+id/selectstate"
style="@style/Edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/location_icon"
android:drawableRight="@drawable/drop_down_arrow"
android:focusable="false"
android:focusableInTouchMode="false"
android:hint="@string/selectstate_txt"
android:inputType="textNoSuggestions|text"
android:text=""
android:maxLines="1"/>
<Spinner
android:id="@+id/statespinner"
android:layout_width="match_parent"
android:layout_height="0dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.30"
android:orientation="vertical"
>
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="@dimen/padding5"
android:padding="@dimen/padding5"
android:src="@drawable/arrow_left"
android:visibility="gone"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="@+id/accept_tnc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:layout_margin="@dimen/padding5"
android:id="@+id/accept_tnc_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/remember_radio_inactive"
/>
<com.app.quizjeetho.Fonts.Gothic_Bold
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/iagree"
android:textColor="@color/white"
/>
<com.app.quizjeetho.Fonts.Gothic_Regular
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/padding5"
android:text="@string/accepttnc"
android:textColor="@color/white" />
</LinearLayout>
<com.app.quizjeetho.Fonts.Gothic_Bold
android:id="@+id/register_button"
style="@style/Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/padding10"
android:text="@string/register_txt" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
现在,当我尝试从全名命中键盘上的下一个按钮时,即使给予nextfocusright
,它也会转到密码而不是手机号码。如果我删除textsize
中提供的style="@style/Edittext"
,则问题已解决,如下所示:
<style name="Edittext">
<!-- Customize your theme here. -->
<item name="android:textSize">@dimen/text16</item>
<item name="android:textCursorDrawable">@null</item>
<item name="android:textColor">@color/white</item>
<item name="android:textColorHint">@color/white</item>
<item name="android:backgroundTint">@color/clrfe</item>
</style>