2015-12-30 157 views
0

我想定製EditText滑塊樣式。看到我下面的截圖。Android如何更改edittext光標樣式

這是默認的滑蓋造型:

This is the default cursor Style

這是我希望看到的:

This is the cursor style I want to customize.

這可能是一個愚蠢的問題,但幾個小時後,谷歌搜索,我只能找到更改光標顏色的方法,但找不到更改滑塊樣式的方法。

這是我使用用於改變光標顏色(color_cursor.xml)的代碼:

<?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="#008000" /> 
</shape> 

我施加的 「機器人:textCursorDrawable =」 @繪製/ color_cursor」到的EditText

感謝

+0

檢查了這個光標是在材料設計庫中可用http://stackoverflow.com/questions/6225995/can-i-change-the-cursor-size-in-android-edit-text-field –

+1

。將您的EditText包裝在TextInputLayout中。 – Emil

+0

你可以試試android:textCursorDrawable(...) – GiapLee

回答

0

爲自己的答案(希望這也將幫助他人): 介紹「Theme.material」後,將的EditText成爲預期的風格,我會はnt查看材料設計

1
android:textSelectHandle="@drawable/your_desired_drawable" 

把它放在editText視圖中。設置你喜歡的drawable。然後更改可繪製xml文件中的顏色。