(android學習筆記)Android View

來源:互聯網
上載者:User

標籤:android   學習筆記   view   textview   樣式   

Android View類:

1.所有的Android組件均是View的子類。

2.所有的組件均可以進行兩種配置,一是通過方法進行配置。二是通過XML進行配置。

TextView類:

1.對於文本組件而言主要的目的是靜態顯示一些文字,類似於標籤的功能。

2.其是android.widget.TextView類,是android.view.View類的直接子類。

3.插入超連結的方法:

1)在XML檔案中的TextView組件配置中寫:android:autoLink=”all” 會自動設定。注意:符號一定要用英文符號。

2)在Activity中如下寫:
<span style="font-family:SimSun;">String html += "<big><I><a href='http://www.baidu.com'>隨時聯絡我</a></I></big>";CharSequence charSequence = Html.fromHtml(html);textView1.setText(charSequence);textView1.setMovementMethod(LinkMovementMethod.getInstance());</span>

之後該textview1即為超連結形式。


關於樣式表檔案:
 

   在Android 當中可能會有很多組件,如果一一進行配置,很麻煩。所以我們可以採用樣式表檔案進行一一配置。省去了開發與維護時的精力。

一般樣式表檔案儲存在項目的res檔案夾下values檔案夾中。檔案為style.xml

定義方式:

<span style="font-family:SimSun;"><resources>   <style name="樣式名稱" parent="父樣式表">       <item name="定義的屬性">屬性內容</item>   </style></resources></span>

其引用通過name裡面定義的名稱進行引用。


定義:

<span style="font-family:SimSun;">resources xmlns:android="http://schemas.android.com/apk/res/android">   <style name="msg_style" > --> 定義組件的樣式名稱       <item name="android:textSize">45dp</item>       <item name="android:textColor">#00FF00</item>       <item name="android:textStyle">bold|italic</item>   </style></resources></span>

引用:

<span style="font-family:SimSun;"><TextView       android:id="@+id/textview1"       style="@style/msg_style" /></span>


(android學習筆記)Android View

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.