Haben Sie versucht, das Hinzufügen android: background = "@ android: Farbe/transparent"?
habe ich das gleiche Beispiel mit diesem Ergebnis
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:background="#00ff00"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="HINT"
android:text="TEXT"
android:background="@android:color/transparent"
android:singleLine="true"/>
<TextView
android:background="#00ff00"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Zweite Art und Weise mit Linien
eine XML-Datei in ziehbar wie diese
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" /> <!--background color of box-->
</shape>
</item>
<item
android:top="-2dp"
android:right="-2dp"
android:left="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="#000000" /> <!-- color of stroke -->
</shape>
</item>
</layer-list>
dann hinzufügen im Ihr Layout dies in Ihrem EditText android hinzufügen: background = "@ ziehbar/edittext_background"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:background="#00ff00"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="HINT"
android:text="TEXT"
android:background="@drawable/edittext_background"
android:singleLine="true"
android:layout_marginBottom="3dp"/>
<TextView
android:background="#00ff00"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
und Sie werden diese
Ja ich denke, dass das funktionieren würde, obwohl ich würde es vorziehen, nicht eine neun Patch für jeden Zustand müssen machen (oder muß diese Logik in jeder App setzen, die eine EditText nutzen will ...) – Xiao
Versuchen Sie dann Padding für TextViews anzuwenden? –
Ja, genau das mache ich, aber es ist ein eklatanter Hack.Hoffe auf eine sauberere Lösung – Xiao