I EditText mit benutzerdefinierten Hintergrund ziehbar haben:entfernen zusätzlich unterstrichen in EditText
EditText Code:
<EditText
android:id="@+id/etName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@{ViewModel.isAllowEdit ? @drawable/profile_et_background_active : @drawable/profile_et_background}"
android:inputType="@{ViewModel.isAllowEdit ? InputType.TYPE_CLASS_TEXT : InputType.TYPE_NULL}"
android:text="@={ViewModel.name}"
android:textColor="@color/main_dark_text_color" />
Ich bin mit android Databinding Bibliothek und MVVM Architektur.
Wenn ViewModel isAllowEdit auf true festgelegt ist, wird EditText background auf @ drawable/profile_et_background_active gesetzt.
Wenn isAllowEdit false EditText hat den Hintergrund auf @ drawable/profile_et_background gesetzt.
Auch ich bin nicht zulässig bearbeiten, indem Sie inputType auf TYPE_NULL, und erlauben Sie bearbeiten, indem Sie inputType auf TYPE_CLASS_TEXT.
@ ziehbar/profile_et_background_active Code:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/main_elements_line_color" />
</shape>
</item>
</layer-list>
@ ziehbar/profile_et_background Code:
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
Wenn bearbeiten darf und Benutzer Start Eingabe von Text in EditText zusätzlichen Unterstrich erscheint unter typisiertem Wort (es gehört nur In den derzeit Wort eingegeben haben, hat alle anderen Teile von EditText Text nicht unterstrichen):
I durch Zugabe von Farbfilter EditText dass Unterstrichen zu entfernen versucht:
et.setColorFilter(getResources().getColor(android.R.color.transparent), PorterDuff.Mode.SRC_IN)
Aber es funktioniert nicht Arbeit.
Wie kann ich diese zusätzliche Unterstreichung entfernen?
UPDATE 1
Ich habe bereits versucht @android hinzuzufügen: Farbe/transparent, und ich bin immer Fehler:
„java.lang.Integer kann nicht gegossen werden, um android.graphics.drawable .Drawable "
beim Wechsel "@ {? ViewModel.isAllowEdit @ ziehbar/profile_et_background_active: @ ziehbar/profile_et_background}"
auf" @ {ViewModel.isAllowEdit @ ziehbar/profile_et_backgro? und_active: @android: Farbe/transparent}“
UPDATE 2
Hinzufügen InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS für mich nicht funktioniert. Also denke ich, das ist nicht das Problem von Spell Checker.
OP hat nicht gebeten, die Unterstreichung des Widgets zu entfernen, sondern diejenige, die unter dem Text erscheint. –
Ich habe das bereits ausprobiert und bekomme den Fehler "java.lang.Integer kann nicht in android.graphics.drawable.Drawable umgewandelt werden" wenn "@ {ViewModel.isAllowEdit? @ Drawable/profile_et_background_active: @ drawable/profile_et_background}" zu "@ {ViewModel.isAllowEdit? @ drawable/profile_et_background_active: @android: color/transparent}" –
@VladMorzhanov Wenn ich richtig liege, wird R als Rechtschreibprüfung unterstrichen? –