Ich benutze eine EditText
Ansicht in meiner Symbolleiste, und wenn das "Häkchen" -Symbol angeklickt wird, wird die App überprüfen, ob alle Felder leer sind oder nicht. Wenn leer ist, wird die Methode setError()
aufgerufen. Aber die Popup-Nachricht sieht seltsam aus (in der folgenden Abbildung). EditText.setError() 's Popup-Nachrichtenlayout sieht seltsam aus
Und ich verstecke weiche Eingabe, es sieht so aus.
Ein weiteres Problem ist, dass eine EditText
Ansicht im Wurzel Layout ist, und, wenn setError()
genannt wird, gescrollt die Ansicht automatisch up (Appbarlayout
ist verdeckt). Wie lässt sich das Layout korrekt unter der Ansicht platzieren?
Ist das das Layout-Design-Problem?
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ActionbarStyle"
app:layout_scrollFlags="scroll|enterAlways|snap">
<EditText
android:id="@+id/et_ItemName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/item_name"
android:inputType="text|textAutoCorrect"
android:maxLength="20"
android:textStyle="bold">
<requestFocus />
</EditText>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/layout_padding"
android:paddingLeft="@dimen/layout_padding"
android:paddingRight="@dimen/layout_padding"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
app:srcCompat="@drawable/ic_money_black_24dp" />
<EditText
android:id="@+id/et_Dollar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="end|right"
android:inputType="numberDecimal"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
app:srcCompat="@drawable/ic_sort_black_24dp" />
<Button
android:id="@+id/btn_SelectCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:gravity="end|right|center_vertical"
android:hint="@string/select_category" />
</LinearLayout>
<EditText
android:id="@+id/et_Note"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/background_border"
android:gravity="top|left"
android:hint="@string/note"
android:inputType="textMultiLine"
android:minLines="1"
android:padding="@dimen/TextPAdding" />
<include
android:id="@+id/view_image_container"
layout="@layout/layout_add_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/widget_padding" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
für testfall entfernen ' ' als versuchen –