すべてのデバイスで Android の edittext カーソルの色を変更したいと考えています。それ、どうやったら出来るの?
質問する
35089 次
5 に答える
19
次のようなドローアブルを使用する必要がありました。
mycursor.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<size android:width="1dp" />
<solid android:color="@android:color/holo_blue_light"/>
<!--make sure its a solid tag not stroke or it wont work -->
</shape>
編集テキストで、カーソルの描画可能な属性を次のように設定します。
<EditText
android:id="@+id/et_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:textCursorDrawable="@drawable/mycursor"
/>
于 2014-09-09T20:58:42.540 に答える
8
すべてのプラットフォームでそれを取得する方法はそのようなものです.
1 - レイアウト フォルダーにある layout.xml を開きます。編集テキストを見つけて設定する
android:cursorVisible="true"
これにより、OS バージョン 11 より前のデバイスのカーソルが設定されます
2 - drawable フォルダーに cursor_drawable.xml を作成します。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<size android:width="1dp" />
<stroke android:color="@color/black"/>
</shape>
3 - フォルダー layout-v11 を作成する
4 - layout.xml を layout-v11 にコピーします。
5 - 編集テキストを見つけて android:textCursorDrawable="@drawable/cursor_drawable" を設定します
これにより、すべてのデバイスと OS でカーソルが表示されます。
于 2012-10-15T09:40:22.307 に答える
7
カーソルの色にandroid:textCursorDrawable
属性を割り当て@null
て設定します。android:textColor
于 2012-07-17T13:34:56.267 に答える
-1
このリンクを参照してください。これを試すことができます
android:textCursorDrawable
于 2012-07-17T13:35:59.553 に答える