gpt4 book ai didi

Android:如何以编程方式检查 TextView 是粗体还是斜体

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:43:26 25 4
gpt4 key购买 nike

我想知道如何构造一个 if 语句来检查 TextView 是粗体还是斜体。请帮忙。谢谢你。

最佳答案

http://developer.android.com/reference/android/widget/TextView.html#getTypeface()

public Typeface getTypeface ()

返回:

the current typeface and style in which the text is being displayed.

if(yourTextViewInstance.getTypeface()!=null){
if(yourTextViewInstance.getTypeface().getStyle()==Typeface.BOLD || yourTextViewInstance.getTypeface().getStyle()==Typeface.ITALIC){
//do your stuff
}
}

关于Android:如何以编程方式检查 TextView 是粗体还是斜体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18012403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com