<bdo id='syuzx'></bdo><ul id='syuzx'></ul>
<legend id='syuzx'><style id='syuzx'><dir id='syuzx'><q id='syuzx'></q></dir></style></legend>

      <tfoot id='syuzx'></tfoot>
    1. <i id='syuzx'><tr id='syuzx'><dt id='syuzx'><q id='syuzx'><span id='syuzx'><b id='syuzx'><form id='syuzx'><ins id='syuzx'></ins><ul id='syuzx'></ul><sub id='syuzx'></sub></form><legend id='syuzx'></legend><bdo id='syuzx'><pre id='syuzx'><center id='syuzx'></center></pre></bdo></b><th id='syuzx'></th></span></q></dt></tr></i><div id='syuzx'><tfoot id='syuzx'></tfoot><dl id='syuzx'><fieldset id='syuzx'></fieldset></dl></div>

    2. <small id='syuzx'></small><noframes id='syuzx'>

      如何更改editText字段上的突出显示颜色

      时间:2023-05-28
    3. <small id='WvKc6'></small><noframes id='WvKc6'>

          <tfoot id='WvKc6'></tfoot>
              <legend id='WvKc6'><style id='WvKc6'><dir id='WvKc6'><q id='WvKc6'></q></dir></style></legend>
                <bdo id='WvKc6'></bdo><ul id='WvKc6'></ul>
              • <i id='WvKc6'><tr id='WvKc6'><dt id='WvKc6'><q id='WvKc6'><span id='WvKc6'><b id='WvKc6'><form id='WvKc6'><ins id='WvKc6'></ins><ul id='WvKc6'></ul><sub id='WvKc6'></sub></form><legend id='WvKc6'></legend><bdo id='WvKc6'><pre id='WvKc6'><center id='WvKc6'></center></pre></bdo></b><th id='WvKc6'></th></span></q></dt></tr></i><div id='WvKc6'><tfoot id='WvKc6'></tfoot><dl id='WvKc6'><fieldset id='WvKc6'></fieldset></dl></div>
                  <tbody id='WvKc6'></tbody>

                本文介绍了如何更改editText字段上的突出显示颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                下面是我在我的 android 应用程序中拥有的自定义编辑文本字段的屏幕截图.当您键入给定的单词时,您当前键入的单词的文本以灰色突出显示并将文本显示为黑色,直到您按下空格键,此时文本按预期变为白色.有没有办法改变突出显示的颜色和突出显示的文本?

                Below is a screen shot of a custom edit text field i have in my android app. While you are type a given word, the text for the word you are currently typing highlights in grey and shows the text as black, until you hit the space bar at which time the text turns white as expected. Is there a way to change the color of the highlight and the text that is highlighted?

                我的编辑文本 xml 看起来像这样

                my edit text xml looks like this

                 <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>
                

                整个布局

                <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>
                

                推荐答案

                通过将这一行添加到我的主题.xml 文件中,我能够更改编辑文本的突出显示:

                I was able to change the highlight of my edit text by adding this line to my themes.xml file:

                <item name="android:textColorHighlight">@color/m_highlight_blue</item>
                

                这篇关于如何更改editText字段上的突出显示颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:根据 EditText 值更改 SeekBar 进度 下一篇:Android 操作栏选项卡和键盘焦点

                相关文章

                    <tfoot id='GbzYr'></tfoot>

                  1. <legend id='GbzYr'><style id='GbzYr'><dir id='GbzYr'><q id='GbzYr'></q></dir></style></legend>

                      <bdo id='GbzYr'></bdo><ul id='GbzYr'></ul>
                    <i id='GbzYr'><tr id='GbzYr'><dt id='GbzYr'><q id='GbzYr'><span id='GbzYr'><b id='GbzYr'><form id='GbzYr'><ins id='GbzYr'></ins><ul id='GbzYr'></ul><sub id='GbzYr'></sub></form><legend id='GbzYr'></legend><bdo id='GbzYr'><pre id='GbzYr'><center id='GbzYr'></center></pre></bdo></b><th id='GbzYr'></th></span></q></dt></tr></i><div id='GbzYr'><tfoot id='GbzYr'></tfoot><dl id='GbzYr'><fieldset id='GbzYr'></fieldset></dl></div>

                    <small id='GbzYr'></small><noframes id='GbzYr'>