C++遍歷文件夾獲得文件列表。本站提示廣大學習愛好者:(C++遍歷文件夾獲得文件列表)文章只能為提供參考,不一定能成為您想要的結果。以下是C++遍歷文件夾獲得文件列表正文
TextView平日用來顯示通俗文本,然則有時刻須要對個中某些文本停止款式、事宜方面的設置。Android體系經由過程SpannableString類來對指定文本停止相干處置,現實運用頂用的比擬多的處所好比聊地利顯示臉色啊,同伙圈或社區中話題的顯示、@石友顯示和點擊等等,症結字顯示分歧色彩……
1、BackgroundColorSpan 配景色
SpannableString spanText = new SpannableString("BackgroundColorSpan"); spanText.setSpan(new BackgroundColorSpan(Color.GREEN), 0, spanText.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
2、ClickableSpan 文本可點擊,有點擊事宜
spannableString.setSpan(new ClickableSpan() { @Override public void onClick(View widget) { spanClickListener.onSpanClick(bean); } @Override public void updateDrawState(TextPaint ds) { super.updateDrawState(ds); //設置畫筆屬性 ds.setUnderlineText(false);//默許有下劃線 } }, matcher.start(), end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tvTopic.setText(spannableString); //假如想完成點擊,必需要設置這個 tvTopic.setMovementMethod(LinkMovementMethod.getInstance());
3、ForegroundColorSpan 文本色彩(遠景色)
spanText = new SpannableString("這是ForegroundColorSpan,看到了嗎"); spanText.setSpan(new ForegroundColorSpan(Color.BLUE), 6, spanText.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
4、MaskFilterSpan 潤飾後果,如隱約(BlurMaskFilter)、浮雕(EmbossMaskFilter)
spanText = new SpannableString("這是MaskFilterSpan,,看到了嗎"); int length = spanText.length(); //隱約(BlurMaskFilter) MaskFilterSpan maskFilterSpan = new MaskFilterSpan(new BlurMaskFilter(3, Blur.OUTER)); spanText.setSpan(maskFilterSpan, 0, length - 10, Spannable. SPAN_INCLUSIVE_EXCLUSIVE); //浮雕(EmbossMaskFilter) maskFilterSpan = new MaskFilterSpan(new EmbossMaskFilter(new float[]{1,1,3}, 1.5f, 8, 3)); spanText.setSpan(maskFilterSpan, length - 10, length, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
7、StrikethroughSpan 刪除線(中劃線)
spanText = new SpannableString("StrikethroughSpan"); spanText.setSpan(new StrikethroughSpan(), 0, 7, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
8、SuggestionSpan
相當於占位符,普通用在EditText輸出框中。當雙擊此文本時,會彈出提醒框選擇一些建議(推舉的)文字,選中的文本將調換此占位符。在輸出法上用的較多。
9、UnderlineSpan 下劃線
spanText = new SpannableString("UnderlineSpan"); spanText.setSpan(new UnderlineSpan(), 0, spanText.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
10、AbsoluteSizeSpan 相對年夜小(文本字體)
spanText = new SpannableString("AbsoluteSizeSpan"); spanText.setSpan(new AbsoluteSizeSpan(20, true), 0, spanText.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
11、DynamicDrawableSpan 設置圖片,基於文本基線或底部對齊。
DynamicDrawableSpan drawableSpan = new DynamicDrawableSpan(DynamicDrawableSpan.ALIGN_BASELINE) { @Override public Drawable getDrawable() { Drawable d = getResources().getDrawable(R.drawable.ic_launcher); d.setBounds(0, 0, 50, 50); return d; } }; DynamicDrawableSpan drawableSpan2 = new DynamicDrawableSpan( DynamicDrawableSpan.ALIGN_BOTTOM) { @Override public Drawable getDrawable() { Drawable d = getResources().getDrawable(R.drawable.ic_launcher); d.setBounds(0, 0, 50, 50); return d; } }; spanText.setSpan(drawableSpan, 3, 4, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); spanText.setSpan(drawableSpan2, 7, 8, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
12、ImageSpan 圖片
spanText = new SpannableString("ImageSpan"); Drawable d = getResources().getDrawable(R.drawable.ic_launcher); d.setBounds(0, 0, 50, 50); spanText.setSpan(new ImageSpan(d), 3, 4, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
13、RelativeSizeSpan 絕對年夜小(文本字體)
spanText = new SpannableString("RelativeSizeSpan"); //參數proportion:比例年夜小 spanText.setSpan(new RelativeSizeSpan(2.5f), 3, 4, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
14、ScaleXSpan 基於x軸縮放
spanText = new SpannableString("ScaleXSpan"); //參數proportion:比例年夜小 spanText.setSpan(new ScaleXSpan(3.8f), 3, 7, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
15、StyleSpan 字體款式:粗體、斜體等
spanText = new SpannableString("StyleSpan"); spanText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 3, 7, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
16、SubscriptSpan 下標(數學公式會用到)
spanText = new SpannableString("SubscriptSpan"); spanText.setSpan(new SubscriptSpan(), 6, 7, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
17、SuperscriptSpan 上標(數學公式會用到)
spanText = new SpannableString("SuperscriptSpan"); spanText.setSpan(new SuperscriptSpan(), 6, 7, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
18、TextAppearanceSpan 文本表面(包含字體、年夜小、款式和色彩)
spanText = new SpannableString("TextAppearanceSpan"); //若需自界說TextAppearance,可以在體系款式長進行修正 spanText.setSpan(new TextAppearanceSpan(this, android.R.style.TextAppearance_Medium), 6, 7, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
19、TypefaceSpan 文本字體
spanText = new SpannableString("TypefaceSpan"); spanText.setSpan(new TypefaceSpan("monospace"), 3, 10, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText);
20、URLSpan 文本超鏈接
spanText = new SpannableString("URLSpan"); spanText.setSpan(new URLSpan("http://blog.csdn.net/u011102153"), 10, spanText.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); mTVText.append("\n"); mTVText.append(spanText); //讓URLSpan可以點擊 mTVText.setMovementMethod(new LinkMovementMethod());
下載:https://github.com/LineChen/SpannableStringDemo
以上就是本文的全體內容,願望對年夜家的進修有所贊助,也願望年夜家多多支撐。