Cursor not showing in EditText on HTC devices

In my application, I am using the cursor color for EditText

.

It works on Samsung devices , but it doesn't appear on HTC One . If I pass the element textCursorDrawable

as null, it will display the default text color as the cursor color, but I want the cursor color in red.

I can't figure out exactly where the problem is. Please help me.

Here's mine EditText

in XML:

<EditText
    android:id="@+id/username_edit"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_weight="90"
    android:background="@null"
    android:ems="10"
    android:hint="user name"

    android:maxLength="60"
    android:paddingLeft="5dp"
    android:singleLine="true"
    android:textColor="@color/black"
    android:textCursorDrawable="@color/appheader_color"
    android:textSize="@dimen/TextSize_medium" >

</EditText>

      

+3


source to share


2 answers


Try adding

android:textCursorDrawable="@null"

<EditText  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textCursorDrawable="@drawable/color_cursor"
    />

      



You can set your own color

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:width="1dp" />
    <solid android:color="#FFFFFF"  /> //#FFFFFF will be replaced by your color code
</shape>

      

+2


source


Try it. This might help you.

Create drawalble xml: cursor_color

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

      



In Edittext:

<EditText
                    android:id="@+id/username_edit"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_weight="90"
                    android:background="@null"
                    android:ems="10"
                    android:hint="user name"

                    android:maxLength="60"
                    android:paddingLeft="5dp"
                    android:singleLine="true"
                    android:textColor="@color/black"
                    android:textCursorDrawable="@drawable/cursor_color"
                    android:textSize="@dimen/TextSize_medium" >


                </EditText>

      

0


source







All Articles