将样式动态地应用到EditText的内容上

        EditText editText = (EditText)findViewById(R.id.editText01);
        
        editText.setText("jiojklj");
        Spannable spannable = (Spannable)editText.getText();
        spannable.setSpan(new BackgroundColorSpan(Color.RED), 1, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 2, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

 

posted @ 2012-11-29 19:53  盗草人  阅读(148)  评论(0编辑  收藏  举报