當前位置:首頁 » 安卓系統 » android游標顏色

android游標顏色

發布時間: 2023-01-13 11:17:10

Ⅰ android中如何更改EditText 的游標顏色急求急求

發現為application設置android:theme="@style/AppTheme",那麼游標顏色會和字體一樣
自定義過theme就會變成白色了,這時候如果背景也是白色,那游標幾乎看不到了,但確實是存在的
修改自定的style文件,為自己的style文件里加上一句parent="android:Theme.Light"就好了
游標顏色會和字體一個顏色
就這樣解決,擺脫android:textCursorDrawable屬性,用api 2.2測試的

Ⅱ android中如何更改EditText 的游標顏色

EditText有一個屬性:android:textCursorDrawable,這個屬性是用來控制游標顏色的
android:textCursorDrawable="@null","@null"作用是讓游標顏色和text
color一樣

1 在代碼中進行設置更改默認提示的字體大小

SpannableString hintStr = new SpannableString(getResources().getString(R.string.search_tittle));// 定義hint的值

AbsoluteSizeSpan ass = new AbsoluteSizeSpan(14, true);// 設置字體大小 true表示單位是SP

hintStr.setSpan(ass, 0, hintStr.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

search_et.setHint(new SpannedString(hintStr));

2 在布局文件中進行設置EditText更改游標的的寬度和顏色

android:textCursorDrawable="@drawable/shape_et_cursor"

shape資源是

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="rectangle">

<size android:width="2dp" />

<solid android:color="#FF5899" />

</shape>

3 EditText常用屬性

android:textCursorDrawable="@null" 控制游標顏色 "@null"不設置顏色和editText的顏色一致 設置顏色要使用

@drawable/shape 屬性

editText.setSelection(2) 使游標移動到制定的位置

editText.requestFocus() 請求出現游標時獲取焦點

editText.clearFocus() 清除游標,失去焦點

editText.setCursorVisible(false) 不出現游標

android:imeOptions="actionSearch" 彈出鍵盤出現搜索按鈕

android:inputType="text" 輸入字元串

Ⅲ 2021-09-15 TextView屬性大全

TextView 是用於顯示字元串的組件,對於用戶來說就是屏幕中一塊用於顯示文本的區域。

TextView 類的層次關系如下:

java.lang.Object
↳ android.view.View
↳ android.widget.TextView

直接子類:

Button,
CheckedTextView,
Chronometer,
DigitalClock,
EditText

間接子類:

AutoCompleteTextView,
CheckBox,
CompoundButton,
ExtractEditText,
MultiAutoCompleteTextView,
RadioButton,
ToggleButton

TextView 類方法
前面是方法,中間解釋,後面為方法的返回值

getDefaultMovementmethod //獲取默認的箭頭按鍵移動方式 //Movementmethod
getText //獲得TextView 對象的文本 //CharSquence
length //獲得TextView 中的文本長度 //Int
getEditableText //取得文本的可編輯對象,通過 這個對象可對TextView 的文本進行操作,如在游標之後插入字元 //Void
getCompoundPaddingBottom //返回底部填充物 //Int
setCompoundDrawables //設置圖像顯示的位置,在 設置該Drawable 資源之前需要調用setBounds(Rect) //Void
//設置Drawable 圖像的顯示位置,但其邊界不變 //Void
setPadding //根據位置設置填充物 //Void
getAutoLinkMask //返回自動連接的掩碼 //Void
setTextColor //設置文本顯示的顏色 //Void
setHighlightColor //設置文本選中時顯示的顏色 //Void
setShadowLayer //設置文本顯示的陰影顏色 //Void
setHintTextColor //設置提示文字的顏色 //Void
setLinkTextColor //設置鏈接文字的顏色 //Void
setGravity //設置當TextView 超出了文本本身時橫向以及垂直對齊 //Void
getFreezesText //設置該視圖是否包含整個文本,如果包含則返回真值,否則返回假值 //Boolean

屬性
android:autoLink //設置是否當文本為URL 鏈接/email/電話號碼/map 時,文本顯示為可點擊的鏈接。可選值(none/web/email/phone/map/all)
android:autoText //如果設置,將自動執行輸入值的拼寫糾正。此處無效果,在顯示輸入法並輸入的時候起作用。
android:bufferType //指定getText()方式取得的文本類別。選項editable 類似於StringBuilder 可追加字元,也就是說getText 後可調用append 方法設置文本內容。
android:capitalize //設置英文字母大寫類型。此處無效果,需要彈出輸入法才能看得到,參見EditView 此屬性說明。
android:cursorVisible //設定游標為顯示/隱藏,默認顯示。
android:digits //設置允許輸入哪些字元。如「1234567890.+-*/%\n()」
android:drawableBottom //在text 的下方輸出一個drawable,如圖片。如果指定一個顏色的話會把text 的背景設為該顏色,並且同時和background 使用時覆蓋後者。
android:drawableLeft //在text 的左邊輸出一個drawable,如圖片。
android:drawablePadding //設置text 與drawable(圖片)的間隔,與drawableLeft、drawableRight、drawableTop、drawableBottom 一起使用,可設置為負數,單獨使用沒有效果。

android:drawableRight //在text 的右邊輸出一個drawable,如圖片。
android:drawableTop //在text 的正上方輸出一個drawable,如圖片。
android:ellipsize //設置當文字過長時,該控制項該如何顯示。有如下值設置:」start」—–省略號顯示在開頭;」end」——省略號顯示在結尾;」middle」—-省略號顯示在中間;」marquee」 ——以跑馬燈的方式顯示(動畫橫向移動)

android:freezesText //設置保存文本的內容以及游標的位置。
android:gravity //設置文本位置,如設置成「center」,文本將居中顯示。
android:hint //Text 為空時顯示的文字提示信息,可通過textColorHint 設置提示信息的顏色。比較奇怪的是TextView 本來就相當於Label,怎麼會不設置Text?!
android:includeFontPadding //設置文本是否包含頂部和底部額外空白,默認為true。
android:inputMethod //為文本指定輸入法,需要完全限定名(完整的包名)。
android:linksClickable //設置鏈接是否點擊連接
android:marqueeRepeatLimit //在ellipsize 指定marquee 的情況下,設置重復滾動的次數,當設置為marquee_forever 時表示無限次。
android:ems //設置TextView 的寬度為N 個字元的寬度。
android:maxEms //設置TextView 的寬度為最長為N 個字元的寬度。
android:minEms //設置TextView 的寬度為最短為N 個字元的寬度。
android:maxLength //限制顯示的文本長度,超出部分不顯示。
android:lines //設置文本的行數,設置兩行就顯示兩行,即使第二行沒有數據。
android:maxLines //設置文本的最大顯示行數,與width 或者layout_width 結合使用,超出部分自動換行,超出行數將不顯示
android:minLines //設置文本的最小行數,與lines 類似。
android:lineSpacingExtra //設置行間距。
android:lineSpacingMultiplier //設置行間距的倍數。
android:password //以小點」.」顯示文本
android:phoneNumber //設置為電話號碼的輸入方式。
android:scrollHorizontally //設置文本超出TextView 的寬度的情況下,是否出現橫拉條。
android:shadowColor //指定文本陰影的顏色,需要與 shadowRadius 一起使用。
android:shadowRadius //設置陰影的半徑。
android:shadowDx //設置陰影橫向坐標開始位置。
android:shadowDy //設置陰影縱向坐標開始位置。
android:singleLine //設置單行顯示。
android:text //設置顯示文本.

android:textAppearance //設置文字外觀。如「?android:attr/textAppearanceLargeInverse」這里引用的是系統自帶的一個外觀,?表示系統是否有這種外觀,否則使用默認的外觀。可設置的值如下:textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInverse

android:textColor //設置文本顏色
android:textColorHighlight //被選中文字的底色,默認為藍色
android:textColorHint //設置提示信息文字的顏色,默認為灰色。與hint 一起使用。
android:textColorLink //文字鏈接的顏色.
android:textScaleX //設置文字之間間隔,默認為1.0f。
android:textSize //設置文字大小,推薦度量單位」sp」,如」15sp」
android:textStyle //設置字形[bold(粗體) 0, italic(斜體) 1, bolditalic(又粗又斜) 2] 可以設置一個或多個,用「|」隔開android:typeface //設置文本字體,必須是以下常量值之一:normal 0, sans 1, serif 2, monospace(等寬字體) 3]

android:height //設置文本區域的高度,支持度量單位:px(像素)/dp/sp/in/mm(毫米)
android:maxHeight //設置文本區域的最大高度
android:minHeight //設置文本區域的最小高度
android:width //設置文本區域的寬度,支持度量單位:px(像素)/dp/sp/in/mm(毫米)。
android:maxWidth //設置文本區域的最大寬度
android:minWidth //設置文本區域的最小寬度

原文鏈接: https://blog.csdn.net/Adomner/article/details/52263987

Ⅳ android Edittext游標下面的小箭頭

  1. 在資源文件drawable下新建一個游標控制color_cursor.xml

<?xmlversion="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle">
<sizeandroid:width="1dp"/>
<solidandroid:color="#008000"/>
</shape>

2.設置EditText:android:textCursorDrawable="@drawable/color_cursor"

android:textCursorDrawable="@null" 表示游標的顏色和字體的顏色一樣

熱點內容
mr底層演算法 發布:2025-07-04 23:14:59 瀏覽:779
怎麼注冊作業盒子密碼 發布:2025-07-04 23:14:51 瀏覽:923
速達伺服器ip 發布:2025-07-04 23:07:38 瀏覽:260
哪裡能下載安卓版刺激戰場 發布:2025-07-04 23:02:27 瀏覽:519
android微信推送消息推送消息 發布:2025-07-04 22:56:52 瀏覽:386
android分享文件 發布:2025-07-04 22:56:40 瀏覽:404
c語言方程的根 發布:2025-07-04 22:55:33 瀏覽:448
什麼電腦單機游戲好玩又免費配置低 發布:2025-07-04 22:51:27 瀏覽:420
真香配置有哪些 發布:2025-07-04 22:49:05 瀏覽:207
安卓在哪裡找游戲 發布:2025-07-04 22:15:25 瀏覽:243