如何让你的EditText斜体? [英] How to make your EditText italicized?
问题描述
android:textStyle="italic"
这并不斜体EDITTEXT。
This does not italicize the editText.
<EditText
android:id="@+id/editTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="italic"
android:singleLine="true"
android:textSize="14dp"
android:background="@null"
android:gravity="center"
android:inputType="textNoSuggestions"
>
</EditText>
你能帮忙吗?非常感谢你提前。
Could you help? Thank you so much in advance.
我现在发现,有一些错误的Galaxy Note 2,当您尝试斜体文字的EDITTEXT。 2013年4月18日
I now found that there is something wrong with Galaxy Note 2, when you try to italicize texts in editText. 4/18/2013
推荐答案
要设置文本为斜体,你可以做到以下几点:
To set text as italic, you can do the following:
EditText.setText(Html.fromHtml(&LT;小&GT;&LT; I&GT;+文本提示这里的+&LT; / I&GT;&LT; /小&GT;));
如果你想斜体文字是一个提示 - 当EditText上是空的 - 例如,你必须实现一个方法来检查文本长度,当它等于零,应用上述code。
If you would like the italic text to be a hint - when the EditText is empty for example - you must implement a method to check the text length, and when it is equal to zero, apply the above code.
试试这个更新选项 -
创建一个新的风格: -
Create a new style:-
<style name="editStyle">
<item name="android:textStyle">italic</item>
<item name="android:textColor">#000000</item>
</style>
和使用这种方式 - 它的工作原理:)
and use it this way - it works :)
<EditText
android:id="@+id/editTxt"
style="@style/editStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="EditText"
android:singleLine="true"
android:textSize="14dp" >
</EditText>
快照: -
SnapShot:-
这篇关于如何让你的EditText斜体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!