1

使用登錄活動模板與最小的SDK API 14從Android Studio中創建項目,然後自定義colorAccent粉紅顏色styles.xml如何改變光標和指針的顏色華爲P9精簡版

<resources> 
<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 

    <item name="colorAccent">#FF4081</item><!-- pink color --> 

</style> 

LG的Nexus 5X能夠生效(測試用棉花糖和牛軋糖): enter image description here

但在華爲P9精簡版(棉花糖)沒有影響: enter image description here

我應該怎麼做才能讓光標+指針的顏色便攜?

請注意colorControlActivated有同樣的問題,不僅colorAccent

[UPDATE]

小米手機3和沒有這樣的問題的測試。 android:textCursorDrawable="@drawable/fb"對這3個設備具有相同的行爲(即只有華爲P9 Lite不能正常工作)。

回答

0

你可以試試這個:

定義的可繪製資源:cursor_green.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> 
<solid android:color="@color/green"/> 
<size android:width="2dp"/> 
</shape> 

然後將其設置爲EditText使用

android:textCursorDrawable="@drawable/cursor_green" 
+0

1.這隻能改變光標(垂直線)顏色,不包括指針(水狀)的顏色。 2.儘管如此,華爲P9 Lite仍然無法使用您的代碼生效,但LG Nexus 5X沒有問題。 –