久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在我的 TextView 中以粗體和多色顯示文本

How do I show text in my TextView with bold and multi coloured(如何在我的 TextView 中以粗體和多色顯示文本)
本文介紹了如何在我的 TextView 中以粗體和多色顯示文本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的要求是在 TextView 中以彩虹色文本和粗體等多色顯示文本,我該如何實現這一點.我需要使用 java 代碼動態顯示它們..

my requirement is to show the Text in the TextView in multicoloured like rainbow color text and Bold, how can I achieve this.and I need to display them dynamically using java code..

TextView text=new TextView(context);
                        text.setText(status);
                    text.setBackgroundResource(R.drawable.grd_btn);
                    text.setGravity(Gravity.CENTER);
                    text.setPadding(2, 0, 2, 0);
                    text.setTypeface(font2,Typeface.BOLD);
                    text.setTextColor(Color.WHITE);

推薦答案

對不起,我的朋友耽擱了.必須解決您的問題,這需要一段時間.所以首先是輸出,

Hey sorry for the delay my friend. Had to work on your problem and it took a while. So first goes the output,

所以假設上面顯示的是您需要的輸出,這里是它的代碼.

So assuming that the above shown is your needed output here is the code to it.

xml 文件

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="@string/hello_world"/>

res 文件(比如 strings.xml)

<color  name="violet">#9400D3</color>
<color  name="indigo">#4B0082</color>
<color  name="blue">#0000FF</color>
<color  name="green">#00FF00</color>
<color  name="yellow">#FFFF00</color>
<color  name="orange">#FF7F00</color>
<color  name="red">#FF0000</color>

您的 java 文件

     TextView textView = (TextView)findViewById(R.id.textView1);
        Shader textShader=new LinearGradient(0, 0, 0, 20,
                new int[]{getResources().getColor(R.color.violet),getResources().getColor(R.color.indigo),
                getResources().getColor(R.color.blue),
                getResources().getColor(R.color.green),
                getResources().getColor(R.color.yellow),
                getResources().getColor(R.color.orange),
                getResources().getColor(R.color.red)},
                new float[]{0,0.2f,0.4f,0.6f,0.8f,0.9f,1}, TileMode.CLAMP);
        textView.getPaint().setShader(textShader);
        textView.setTextSize(20);

就是這樣.對于您的大膽風格,請點擊我之前回答的以下鏈接,

That's it. And for your bold style follow the below link of my previous answer,

https://stackoverflow.com/a/5169604/603744

這篇關于如何在我的 TextView 中以粗體和多色顯示文本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 久久亚洲春色中文字幕久久久 | 午夜爽爽男女免费观看hd | 在线观看视频福利 | 国产精品成人免费 | 成人一区二区在线 | 国产综合av | 亚洲欧美成人在线 | 久草新在线 | 欧美性精品 | 久久久一二三 | 久久久久久久久久久久久9999 | 欧洲成人免费视频 | 日日射夜夜骑 | 天天影视综合 | 国产色婷婷| 久久精点视频 | 毛片视频免费观看 | 国产精品日韩欧美一区二区三区 | 久久综合久色欧美综合狠狠 | 日日噜噜噜夜夜爽爽狠狠视频, | 成人激情视频免费观看 | 久久99久久99久久 | 看毛片的网站 | 四季久久免费一区二区三区四区 | 亚洲日本欧美日韩高观看 | 午夜99 | 欧美激情va永久在线播放 | 天天操夜夜操 | 欧美性影院 | 欧美日韩免费在线 | 国产精品久久网 | 一区二区三区国产精品 | 一级毛片免费视频 | 欧美专区日韩专区 | 99精品亚洲国产精品久久不卡 | 成人免费一区二区三区视频网站 | 日韩一区二区在线播放 | 春色av| 中文字幕国产精品视频 | 美女一区 | 国产人成精品一区二区三 |