[英]Make editText hint italic?
How do you do this in xml, can you? 你是怎么用xml做的,可以吗?
I see this in a related question for the java code to do it, check length is 0 and: 我在java代码的相关问题中看到了这一点,检查长度为0并且:
EditText.setText(Html.fromHtml("<small><i>" + "Text Hint Here" + "</i></small>"));
But can you just do it from xml? 但你能从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"
/>
try like this in XML 在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 for making italic word use like this android:textStyle="italic"
使提示使用
android:hint="hint"
并使用斜体字这样使用android:textStyle="italic"
updated: 更新:
here is the XML try this, I have tested in my notebook works fine. 这里是XML试试这个,我在我的笔记本上测试过的工作正常。
<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>
Better use java code.use Typeface
. 更好地使用java code.use
Typeface
。 Put your font file in assest folder. 将您的字体文件放在assest文件夹中。 And then write below code.
然后写下面的代码。
italic = Typeface.createFromAsset(getAssets(), "Your font file");
editText.setTypeface(italic);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.