如何检查文本是否为粗体?

时间:2015-04-08 02:16:53

标签: android textview

我已经设置了Text TextView Bold,现在想要以编程方式检查文本是否粗体。请帮我如何以编程方式检查它。 实际上我的布局中有太多TextView,所以我首先找到textView的实例然后检查它是粗体,斜体还是正常。我使用下面的代码来检查它是否适用于应用程序崩溃

 private void findAllEdittexts(ViewGroup viewGroup) {
    int count = viewGroup.getChildCount();
    for (int i = 0; i < count; i++) {
        View view = viewGroup.getChildAt(i);
        if (view instanceof ViewGroup)
            findAllEdittexts((ViewGroup) view);
        else if (view instanceof AutoFitTextView) {
            AutoFitTextView textView_ = (AutoFitTextView) view;
            String Temp__=textView_.getText().toString();
            Boolean temp_isBold=false;
            Boolean temp_isItalic=false;
            Boolean temp_isNorlmal=false;
            if(textView_.getTypeface().getStyle()==Typeface.BOLD)
                temp_isBold=true;
            if(textView_.getTypeface().getStyle()==Typeface.ITALIC)
                temp_isItalic=true;
            if(textView_.getTypeface().getStyle()==Typeface.NORMAL)
                temp_isNorlmal=true;
        }
    }

}

0 个答案:

没有答案
相关问题