wie change highlight color auf editText-Feld
Unten ist ein Screenshot eines benutzerdefinierten text Bearbeiten-Feld habe ich in meiner android app. Während Sie geben ein gegebenes Wort, den text für das Wort, das Sie gerade eingegeben-highlights in Grau und zeigt den text als schwarz, bis Sie drücken Sie die Leertaste, zu welcher Zeit der text wird in weiß angezeigt, wie erwartet. Gibt es eine Möglichkeit, ändern Sie die Farbe der highlight und der text, der markiert ist?
mein edit-text-xml sieht wie folgt aus
<EditText
android:id="@+id/searchField"
android:layout_width="160dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:background="@null"
android:cursorVisible="true"
android:ems="10"
android:textColor="@color/white"
android:textColorHighlight ="#ff0000"
android:textCursorDrawable="@null" >
</EditText>
das gesamte layout
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!--
As the main content view, the view below consumes the entire
space available using match_parent in both dimensions.
-->
<RelativeLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
<fragment
android:id="@+id/map"
android:name="com.sapientnitro.inhouse.drop.components.DRPCustomMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageButton
android:id="@+id/btn_center_local"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="15dp"
android:background="@drawable/btn_center_on_local_up" />
<RelativeLayout
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#ddffffff" >
<ImageButton
android:id="@+id/btn_menu"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="12dp"
android:layout_toLeftOf="@+id/btn_search"
android:background="@drawable/btn_menu_up" />
<ImageButton
android:id="@+id/btn_create"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="12dp"
android:layout_toRightOf="@+id/btn_search"
android:background="@drawable/btn_create_up" />
<ImageButton
android:id="@+id/btn_search"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="@drawable/btn_search_up" />
</RelativeLayout>
<LinearLayout
android:id="@+id/search"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ddffffff"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#dd00cccb" >
<ImageView
android:id="@+id/searchBox"
android:layout_width="238dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:src="@drawable/search_field" />
<ImageView
android:id="@+id/clear"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="220dp"
android:src="@drawable/btn_clear_field" />
<EditText
android:id="@+id/searchField"
android:layout_width="160dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:background="@null"
android:cursorVisible="true"
android:ems="10"
android:textColor="@color/white"
android:textColorHighlight ="@color/white"
android:textCursorDrawable="@null" >
</EditText>
<TextView
android:id="@+id/cancelBTN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:textColor="@color/white"
android:textSize="22dp"
android:text="@string/cancel" />
</RelativeLayout>
<ScrollView
android:id="@+id/search_results_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:paddingTop="2dp"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/search_results_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/header_artists"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="@+id/results_artists"
android:layout_width="match_parent"
android:layout_height="150dp" />
<RelativeLayout
android:id="@+id/header_followers"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="@+id/results_followers"
android:layout_width="match_parent"
android:layout_height="150dp" />
<RelativeLayout
android:id="@+id/header_places"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="@+id/results_places"
android:layout_width="match_parent"
android:layout_height="150dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="255dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#dd00cccb"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="@drawable/selector_transparent" />
<ListView
android:id="@+id/right_drawer"
android:layout_width="255dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#dd00cccb"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="@drawable/selector_transparent" />
</android.support.v4.widget.DrawerLayout>
Wie haben Sie den Stil Ihres Kopf - /edittext so ?
wie, was? einfach den hintergrund auf null, und ein Bild wird es
Hast du eine Lösung finden? Ich habe das gleiche Problem 🙁
wie, was? einfach den hintergrund auf null, und ein Bild wird es
Hast du eine Lösung finden? Ich habe das gleiche Problem 🙁
InformationsquelleAutor erik | 2013-12-17
Du musst angemeldet sein, um einen Kommentar abzugeben.
Konnte ich ändern, das highlight in meinem text Bearbeiten durch hinzufügen dieser Zeile in meiner themes.xml Datei:
Tun, wie Sie wissen, wie man dieses Programm ?
InformationsquelleAutor l-l
Einfach, verwenden Sie einfach TextHightLight Eigenschaft im XML-Modus
[Bild im Anhang hier ist, weil für einen Kommentar unten]
und wenn ich es Tue, das ist, wie es aussieht
es sollte funktionieren. eigentlich habe ich die gleiche Art von Anpassung, die ich verwendet habe, auf ein Projekt. und ich habe gerade versucht deinen genauen code in ein mock-app und es funktioniert einfach gut
ich denke, Sie werden anpassen der action-bar. kannst du mir deine Aktionsleiste oder die angepassten xml-code, damit ich herausfinden kann?
Und haben Sie überprüfen Sie die theme overrides in style.xml? weil ich verwendet, die den gleichen code und es funktioniert perfekt!
prüfen Sie einfach meine Antwort, die ich angehängt ein snapshort und die oben Sie sehen, ist ein EditText, die in blau hervorgehoben
InformationsquelleAutor Kirk
Und wenn Sie zum ändern der Marker-Griff, dann sollten Sie
android:textColorHighlight
ist für highlight-Farbe,colorAccent
ist für die cursor-Farbe.InformationsquelleAutor Abhijeet
Code:
InformationsquelleAutor Cristan
Sollten Sie verwenden
android:textColorHighlight
im EditText element in Ihr layout-xml-DateiInformationsquelleAutor Dreagen
Im material design, erhalten Sie die Standard-Aufstieg Farbe in der Art, so dass das auswählen von text und anderen Thema wäre nach dieser Farbe. Sie können dies ändern, Aufstieg der Farbe in der folgenden Art und Weise -
Gehen, um die style.xml und ändern Sie die folgenden color -
InformationsquelleAutor Mridul Shrivastava
sollten Sie mithilfe einer Auswahl von text ändern der Farben:
Dann stellen Sie Ihre textColor-Eigenschaft @drawable/selector_name
InformationsquelleAutor rachit
diesen code verwenden,könnte die Hilfe, die Sie
InformationsquelleAutor Pankaj Arora