我正在将登录屏幕布局与Android Studio 3.0集成,但在设置输入类型密码时会产生渲染问题。
以下是我的示例XML文件。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<AutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/arial"
android:hint="@string/prompt_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLines="1"
android:nextFocusDown="@id/password"
android:nextFocusForward="@id/password"
android:singleLine="true"
android:textSize="@dimen/text_normal" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/arial"
android:hint="@string/prompt_password"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionSend"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:textSize="@dimen/text_normal" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check_remember"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="@font/arial"
android:text="Remember Me"
android:textColor="@color/colorAccent" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="@dimen/lable_height"
android:layout_weight="1"
android:clickable="true"
android:fontFamily="@font/arial"
android:gravity="right|center_vertical"
android:onClick="forgotPassword"
android:textSize="@dimen/text_normal" />
</LinearLayout>
<Button
android:id="@+id/sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="@font/arial"
android:onClick="attemptLogin"
android:text="@string/action_sign_in"
android:textColor="@color/white"
android:textSize="@dimen/text_normal"
android:textStyle="bold" />
</LinearLayout>
内部密码编辑文本如果我删除android:inputType="textPassword"
,它会完美呈现。否则会产生渲染问题。
以下是我在布局编辑器中看到的错误的屏幕截图:
详情错误
java.lang.IndexOutOfBoundsException: Index: 0
at java.util.Collections$EmptyList.get(Collections.java:4454)
at android.graphics.BidiRenderer.getScriptFont(BidiRenderer.java:300)
at android.graphics.BidiRenderer.getScriptRuns(BidiRenderer.java:281)
at android.graphics.BidiRenderer.renderText(BidiRenderer.java:133)
at android.graphics.BidiRenderer.renderText(BidiRenderer.java:108)
at android.graphics.Paint_Delegate.measureText(Paint_Delegate.java:1310)
at android.graphics.Paint_Delegate.nGetTextAdvances(Paint_Delegate.java:972)
at android.graphics.Paint.nGetTextAdvances(Paint.java)
at android.graphics.Paint.getTextRunAdvances(Paint.java:2287)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:181)
at android.text.TextUtils.setPara(TextUtils.java:1550)
at android.text.TextUtils.ellipsize(TextUtils.java:1257)
at android.text.TextUtils.ellipsize(TextUtils.java:1225)
at android.text.TextUtils.ellipsize(TextUtils.java:1203)
at android.support.design.widget.CollapsingTextHelper.calculateUsingTextSize(CollapsingTextHelper.java:610)
at android.support.design.widget.CollapsingTextHelper.calculateBaseOffsets(CollapsingTextHelper.java:430)
at android.support.design.widget.CollapsingTextHelper.recalculate(CollapsingTextHelper.java:651)
at android.support.design.widget.TextInputLayout.onLayout_Original(TextInputLayout.java:1394)
at android.support.design.widget.TextInputLayout.onLayout(TextInputLayout.java)
at android.view.View.layout(View.java:19623)
at android.view.ViewGroup.layout(ViewGroup.java:6095)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19623)
at android.view.ViewGroup.layout(ViewGroup.java:6095)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.widget.ScrollView.onLayout(ScrollView.java:1552)
at android.view.View.layout(View.java:19623)
at android.view.ViewGroup.layout(ViewGroup.java:6095)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19623)
at android.view.ViewGroup.layout(ViewGroup.java:6095)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19623)
at android.view.ViewGroup.layout(ViewGroup.java:6095)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19623)
at android.view.ViewGroup.layout(ViewGroup.java:6095)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
at android.view.View.layout(View.java:19623)
at android.view.ViewGroup.layout(ViewGroup.java:6095)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:346)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:546)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:680)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
我错过了什么吗?