Make the cursor textText italic?

How do you do it in xml, can you?

I see this in the linked question for java code, to do this check the length 0 and:

EditText.setText(Html.fromHtml("<small><i>" + "Text Hint Here" + "</i></small>"));

      

But can you just do it from xml?

EDIT:

<EditText
        android:id="@+id/term_entry"
        android:layout_width="500dp"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@+id/scrllyout"
        android:imeOptions="actionNone|flagNoExtractUi"
        android:inputType="text|textImeMultiLine"
        android:singleLine="true"
        android:hint="Enter Command"
        android:textStyle="italic"
        android:textColorHint="#30AAAAAA"
        />

      

+3


source to share


2 answers


try this in XML

<EditText
    android:id="@+id/editText1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"  
    android:hint="hint" 
    android:textStyle="italic" > 
</EditText>

      

to make hint use android:hint="hint"

and to use the word italic useandroid:textStyle="italic"



update:

here is the XML, try this, I tested in my laptop perfectly.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >


<EditText
    android:id="@+id/term_entry"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_toRightOf="@+id/scrllyout"
    android:hint="Enter Command"
    android:imeOptions="actionNone|flagNoExtractUi"
    android:inputType="text|textImeMultiLine"
    android:singleLine="true"
    android:textColorHint="#ffffff"
    android:textStyle="italic" />

</LinearLayout>

      

0


source


Better to use java code.use Typeface

. Place your font file in your assest folder. And then write below code.



italic = Typeface.createFromAsset(getAssets(), "Your font file"); 
editText.setTypeface(italic);  

      

0


source







All Articles