1. 程式人生 > >API 23 widget.TextView——屬性分析

API 23 widget.TextView——屬性分析

參閱http://android.xsoftlab.net/reference/android/widget/TextView.html

public class

TextView

extends View

implements ViewTreeObserver.OnPreDrawListener  

Added in API level 1

java.lang.Object

     ↳ android.widget.TextView

已知直接子類

AppCompatTextView

Button

CheckedTextView

Chronometer

DigitalClock

EditText

RowHeaderView

TextClock

【概述】

TextView用於向用戶顯示文字,並可選擇允許編輯它。

TextView是一個完整的文字編輯器,但是基本類配置為不允許編輯;其子類EditText可對文字進行編輯。

設定XML屬性android:textIsSelectable=true或者呼叫setTextIsSelectable(true),可允許使用者對TextView的文字內容進行復制/貼上操作。

備註:

使用<TextView>來輸入文字通常是一個錯誤,您應該使用<EditText>

EditTextTextView的一個子類,一些編輯支援由TextView提供,因此可以在TextView上設定一些與輸入相關的屬性。 但是,使用TextView和輸入屬性通常是剪下和貼上錯誤。 要輸入文字,您應該使用<EditText>。 這個檢查也檢查TextView的子類,如ButtonCheckBox,因為它們有相同的問題:它們不應該與可編輯的屬性一起使用。

【總結】

【巢狀類】

列舉TextView.BufferType    API1

介面TextView.OnEditorActionListenerAPI3

TextView.SavedState

API1

XML屬性】

android:autoLink

API 1

關聯方法:setAutoLinkMask(int mask)

屬性說明: 設定是否顯示為超連結(none/web/email/phone/map/all) 預設為none

可以是以下常量之一:

none 不匹配。預設值。

web  匹配URL地址,單擊使用瀏覽器開啟

email匹配郵箱地址,單擊發送郵件

phone匹配電話號碼,單擊撥打電話

map  匹配地圖地址,單擊使用google地圖開啟,支援英文

all  匹配上述四種格式

它對應的全域性資源符號是autoLink

TextView的內容既包含漢字又包含網址。如要想成功實踐超連結功能,就必須在漢字後新增空格或者換行,否則地址就是此TextView的所有內容。

HTML解析超連結:通過Spanned物件設定text,而通過HTMLformHTML來獲取Spanned物件

textView.setText(Html.fromHtml("百度:<a href='http://www.baidu.com'>http://www.baidu.com</a>

<h1><i><font color='#000FFF'>h1號字 斜體 藍色</font></i>"));

android:autoText

API 1

關聯方法:setKeyListener(KeyListener input)

屬性說明: 如果true,指定此TextView有一個文字輸入法,並自動糾正一些常見的拼寫錯誤。預設false

可以是一個布林值(boolean),true”或“false”。

可以引用一個資源(格式:@[package:]type:name)或者是包含這種型別值的主題屬性(格式:?[package][type:]name)。

它對應的全域性資源符號是autoText

全域性屬性autoTextAPI 3被棄用,使用inputType代替。

AndroidautoText不應使用在TextView,應使用在EditView

android:breakStrategy

API 23

關聯方法:setBreakStrategy(intbreakStrategy)

屬性說明:打破策略(控制段落佈局)。

可以是以下常量之一:

simple          0

high_quality   1

balanced       2段落長度平衡

它對應的全域性資源符號是breakStrategy

android:bufferType

API 1

關聯方法:setText(CharSequence,TextView.BufferType)

屬性說明:指定getText()方式取得的文字類別。確定getText()將返回的最小型別。

可以是以下常量之一:

normal    預設。

editable  類似於StringBuilder可追加字元,getText後可呼叫append方法設定文字內容。

spannable 則可在給定的字元區域使用樣式

它對應的全域性資源符號是bufferType

有意思的是 Editable繼承了Spannable所以具備較多的功能。

注意,EditTextLogTextBox總是返回Editable,即使你在這裡指定的功能更強大。

android:capitalize

API 1

關聯方法:setKeyListener(KeyListener input)

屬性說明:設定英文字母大寫型別

可以是以下常量之一:

none       不轉換預設值。

sentences  每一個句子首字母大寫

words      每一個單詞首字母大寫

characters 每一個英文字母都大寫

它對應的全域性資源符號是bufferType

全域性屬性capitalizeAPI 3被棄用,使用inputType代替。

Androidcapitalize不應使用在TextView,應使用在EditView

android:cursorVisible

API 1

關聯方法:setCursorVisible(boolean visible)

屬性說明:設定游標為顯示/隱藏,預設顯示。如果設定false,即使選中了也不顯示游標欄。

可以是一個布林值(boolean),true”或“false”。

還可以引用一個資源(格式:@[package:]type:name)或者是包含這種型別值的主題屬性(格式:?[package][type:]name)。

它對應的全域性資源符號是cursorVisible

AndroidcursorVisible不應使用在TextView,應使用在EditView

設定EditText游標在右邊,輸入內容從右往左。Androidgravity=right/end

android:digits

API 1

關聯方法:setKeyListener(KeyListener input)

屬性說明:設定允許輸入哪些字元。如1234567890.+-*/% ()0123456789xyzXYZ。常用於密碼驗證。

可以是一個字串值(string),使用\\;”等轉義字元,“\\n”或“\\uxxxxUnicode字元。

還可以引用一個資源(格式:@[package:]type:name)或者是包含這種型別值的主題屬性(格式:?[package][type:]name)。

它對應的全域性資源符號是digits

Androiddigits不應使用在TextView,應使用在EditView

android:drawablePadding

API 1

關聯方法:setCompoundDrawablePadding(int pad)

屬性說明:設定文字框內文字與影象之間的間距,與drawableLeftdrawableRightdrawableTopdrawableBottom一起使用,可設定為負數,單獨使用沒有效果。

可以是一個帶有單位的浮點型尺寸值(float),如:14.5sp”。有效的單位包括:px(畫素)dp(密度無關的畫素)sp(基於引用字型的尺寸來縮放的畫素)in(英寸)mm(毫米)

可以引用一個資源(格式:@[package:]type:name)或者是包含這種型別值的主題屬性(格式:?[package][type:]name)。

它對應的全域性資源符號是drawablePadding

android:drawableTop

API 1

關聯方法:setCompoundDrawablesWithIntrinsicBounds(int left,int top,int right,int bottom)

屬性說明:在文字框頂部繪製指定影象。

android:drawableBottom

API 1

關聯方法:setCompoundDrawablesWithIntrinsicBounds(int left,int top,int right,int bottom)

屬性說明:在文字框底部繪製指定影象。

android:drawableLeft

API 1

關聯方法:setCompoundDrawablesWithIntrinsicBounds(int left,int top,int right,int bottom)

屬性說明:在文字框左邊繪製指定影象。

android:drawableRight

API 1

關聯方法:setCompoundDrawablesWithIntrinsicBounds(int left,int top,int right,int bottom)

屬性說明:在文字框右邊繪製指定影象。

android:drawableStart

API 14

關聯方法:setCompoundDrawablesRelativeWithIntrinsicBounds(int start,int top,int end,int bottom)

屬性說明:在文字框開始處繪製指定影象。

android:drawableEnd

API 14

關聯方法:setCompoundDrawablesRelativeWithIntrinsicBounds(int start,int top,int end,int bottom)

屬性說明:在文字框結尾處繪製指定影象。

可以引用一個資源(格式:@[package:]type:name)或者是包含這種型別值的主題屬性(格式:?[package][type:]name)。

可以是一個顏色值(color),格式#rgb”、”#argb”、”#rrggbb”、”#aarrggbb”。

它對應的全域性資源符號是drawableTopdrawableBottomdrawableLeftdrawableRightdrawableStartdrawableEnd

setCompoundDrawables(Drawable left,Drawable top,Drawable right,Drawable bottom)                 API 1

setCompoundDrawablesRelative(Drawablestart,Drawable top,Drawableend,Drawable bottom)                 API 17

Drawable必須已經呼叫了setBounds(Rect)

setCompoundDrawablesWithIntrinsicBounds(Drawable left,Drawable top,Drawable right,Drawable bottom) API 1

setCompoundDrawablesWithIntrinsicBounds(int left,int top,int right,int bottom)                                API 3

setCompoundDrawablesRelativeWithIntrinsicBounds(Drawablestart,Drawable top,Drawableend,Drawable bottom) API 17

setCompoundDrawablesRelativeWithIntrinsicBounds(intstart,int top,intend,int bottom)                     API 17

Drawable的邊界將被設定為他們的內在邊界。

android:drawableTint

API 23

關聯方法:setCompoundDrawableTintList(ColorStateList tint)

屬性說明:為文字的影象指定顏色。

可以是一個顏色值(color),格式#rgb”、”#argb”、”#rrggbb”、”#aarrggbb”。

還可以引用一個資源(格式:@[package:]type:name)或者是包含這種型別值的主題屬性(格式:?[package][type:]name)。

它對應的全域性資源符號drawableTint

android:drawableTintMode

API 23

關聯方法:setCompoundDrawableTintMode(PorterDuff.Mode tintMode)

屬性說明:混合模式用於調節文字影象的顏色,如顏色漸變之類的

可以是以下常量之一:

src_over

src_in

src_atop

multiply

screen

add

它對應的全域性資源符號drawableTintMode

android:editable

相關推薦

API 23 widget.TextView——屬性分析

參閱:http://android.xsoftlab.net/reference/android/widget/TextView.html public class TextVie

API 25 (Android 7.1.1 API) widget.TextView——屬性分析

Android API 25 (Android 7.1.1)  TextView public class TextView extends View implements ViewTr

API 23 view.View——屬性分析

public class View extends Object implements Drawable.Callback KeyEvent.Callback Accessib

API 23 inputmethodservice.KeyboardView——屬性分析

 參閱:http://android.xsoftlab.net/reference/android/inputmethodservice/KeyboardView.html public cl

API 25 (Android 7.1.1 API) widget.ImageView——屬性分析

Android API 25 (Android 7.1.1) ImageView public class ImageView extends View Added in API level

android中window和windowManager原始碼分析(android-api-23

一、前言 在android中window無處不在,如activity、dialog、toast等。它是view所依附的載體,每個window都對應於一個View和一個ViewRootImpl。ViewRootImpl就是Window和view的連線紐帶。windowMana

[CVE-2017-5487] WordPress <=4.7.1 REST API 內容註入漏洞分析與復現

tps 文章 分析 請求 利用 api文檔 each includes 什麽 不是很新的漏洞,記錄下自己的工作任務 漏洞影響: 未授權獲取發布過文章的其他用戶的用戶名、id 觸發前提:wordpress配置REST API 影響版本:<= 4.7 0x01漏洞

《淘寶網》之系統質量屬性分析

易用性 期待 png 想要 範圍 其中 響應 post 系統 結合6個常見的系統質量屬性是:可用性、可修改性、性能、安全性、可測試性、易用性分析如下:   其中,1.可用性是與系統張合後果有關,指系統正常運行時間的比例。        結合淘寶網如:      2.可修改性

基於淘寶網的軟件質量屬性分析

屬性 及其 防止 就是 ima 安全 能力 -h mage 此次寫的是極具淘寶網的軟件質量屬性分析 1、可用性分析 可用性為系統能正常為用戶提供服務的時間比例。可用性與系統故障及其相關後果有關,當系統不再提供其規範中所說明的服務時,也就出現了系統故障。 公式為 場景:淘寶網

淘寶網的軟件質量屬性分析

alt 高速 測試 性能分析 分享 技術 服務 OS 質量 1.可用性: 場景:雙十一購物狂歡,海量用戶同時使用系統。 2.可修改性: 3.性能分析: 性能反應的是系統的響應能力。性能與時間有關。事件(中斷、消息、用戶請求或時間已到)發生時,系統必須對其做出響應。也

《淘寶網》質量屬性分析

問題 度量 後臺 處理 取消 環境 模式 nbsp 發生 以《淘寶網》為例,描繪質量屬性的六個常見屬性場景。 1、可用性分析 可用性分析所關註的方面包括:如何檢測系統故障,系統故障發生的頻度,出現故障時會發生什麽情況,允許系統有多長時間非正常運行,什麽時候可以安全地出現

[Android] TextView 屬性說明

sch roi rec ray -- out androi wid itl 示例: <TextView android:id="@+id/tvNewDevice" android:layout_width="0

2018/10/04-網路API-《惡意程式碼實戰分析

  惡意程式碼通常依賴於網路函式來完成它的骯髒工作,而Windows API函式中就有很多可以進行網路通訊。建立網路特徵的任務是複雜的,我們這裡的目標,是向你如何識別和理解常見的網路函式,這樣你就可以辨別出一個惡意程式在使用這些函式時會做些什麼。   在Windows的網路選項中,惡意程式碼最普遍使用的是伯

Attempt to invoke virtual method 'void android.widget.TextView.setText錯誤

整了接近一個小時的錯誤,有時候不能僅僅因為AS的報錯就跟著報錯語句zhao找原因,有時候可能因為隨著一個Activity的增多,導致很多長得相似(比如userName,user_name,tv_userName,tv_user_name),此時你找到的id並不是對應介面所具有的id,也就是說是別的介

AI世界-行人屬性分析

AI世界花哨技術展示 AI世界-跨鏡追蹤 AI世界-行人屬性分析 AI世界- 客流統計 AI世界-人體關鍵點 AI世界-熱力圖 AI世界-換臉 AI世界-人臉PS AI世界-三維人臉重建 AI世界-人臉密集關鍵點 AI世界-車輛檢測

ajax屬性分析

$.ajax({     utl:bashpath+"urlPatterns",     type:"post",     datatype:json,     data : {         method:"getDatabase" //相當於request.setAtr

在centos linux下用django搭建web服務,提供api對句子進行情感分析

在centos linux下搭建web服務 這兩天因為實驗室和小米的專案需要我搭建一個web服務返回產品評論的情感極性概率,我一個伺服器小白只好從零摸索搭建伺服器,遇到了很多無從下手的問題,計算機真的令人崩潰2333,寫個部落格記錄一下。 使用到的工具:

(十三)ArcGIS API For Javascript之網路分析

require(["esri/map", "dojo/on", "dojo/dom", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/tas

從const int *p、int* const p到this指標的const屬性分析

一、指標和const 總體來說:如果關鍵字const出現在星號(*)左邊,表示被指物是常量;如果出現在星號右邊,表示指標自身是常量;如果出現在星號兩邊,表示被指物和指標兩者都是常量。 1、const int *p:指向常量的指標(pointer to const) (1)

TextView屬性大全及跑馬燈效果

TextView控制元件常見屬性: android:autoLink :設定是否當文字為URL連結/email/電話號碼/map時,文字顯示為可點選的連結。可選值(none/web /email/phone/map/all) android:autoTex