最近因為想著重新把這個插件撿起來,把view的屬性慢慢的全部補上,所以順便了解一下各個屬性,在這里列舉View的屬性,含義,以及代碼設置。
簡書Markdown編輯器實在是渣,只能把表格換成下面這種形式
- android:id
void setId(int);
設置id,單個布局中保持唯一。
可以用View.generateViewId()
來生成。
- android:accessibilityLiveRegion
void setAccessibilityLiveRegion(int);
輔助功能,在該視圖更改時是否應通知用戶。
View.ACCESSIBILITY_LIVE_REGION_NONE(xml:none)
不通知;
View.ACCESSIBILITY_LIVE_REGION_POLITE(xml:polite)
通知;
View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE(xml:assertive)
打斷語音,并通知;
- android:accessibilityTraversalAfter
void setAccessibilityTraversalAfter(int);
輔助功能,設置在輔助功能遍歷中訪問此視圖的視圖的ID。
屏幕閱讀器必須在此視圖的內容之前訪問另一視圖的內容。
(反正我沒看懂)
- android:accessibilityTraversalBefore
void setAccessibilityTraversalBefore(int);
輔助功能,設置在輔助功能遍歷中訪問此視圖的視圖的ID。
屏幕閱讀器必須在此視圖的內容之前訪問此視圖的內容。
(這個也沒看懂)
- android:alpha
void setAlpha(float);
透明度,值在0-1之間。
0為透明,1為不透明。
- android:autofillHints
void setAutofillHints(String...);
自動填充各種信息。
View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE(xml:creditCardExpirationDate)
信用卡到期日期;
View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY(xml:creditCardExpirationDay)
信用卡到期日;
View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH(xml:creditCardExpirationMonth)
信用卡到期月;
View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR(xml:creditCardExpirationYear)
信用卡到期年;
View.AUTOFILL_HINT_CREDIT_CARD_NUMBER(xml:creditCardNumber)
信用卡卡號;
View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE(xml:creditCardSecurityCode)
信用卡安全密碼;
View.AUTOFILL_HINT_EMAIL_ADDRESS(xml:emailAddress)
郵箱地址
View.AUTOFILL_HINT_NAME(xml:name)
用戶真名;
View.AUTOFILL_HINT_PASSWORD(xml:password)
用戶密碼;
View.AUTOFILL_HINT_PHONE(xml:phone)
電話號碼;
View.AUTOFILL_HINT_POSTAL_ADDRESS(xml:postalAddress)
郵寄地址;
View.AUTOFILL_HINT_POSTAL_CODE(xml:postalCode)
郵寄編號;
View.AUTOFILL_HINT_USERNAME(xml:username)
用戶名;
- android:background
void setBackgroundColor(int);
void setBackgroundResource(int);
void setBackgroundDrawable(Drawable);
void setBackground(Drawable);//api 16
view的背景,可以使用顏色圖片等。
- android:backgroundTint
void setBackgroundTintList(ColorStateList);
將設置的顏色和原來的背景進行一個疊加。
根據backgroundTintMode來疊加。
- android:backgroundTintMode
void setBackgroundTintMode(PorterDuff.Mode);
背景疊加模式PorterDuff.Mode。
- android:clickable
void setClickable(boolean);
是否可點擊
- android:contentDescription
void setContentDescription(CharSequence);
對于一些視力有障礙的用戶,無法理解這個控件是做什么的。
如果用戶安裝了輔助瀏覽工具比如TalkBack,這時用戶點擊這個控件,android系統會自動使用人聲朗讀控件android:contentDescription屬性說指向的內容。
這樣用戶就可以知道這個控件是做什么用的。
這個屬性的主要功能就是為視力有障礙的人增加對控件的解釋。
- android:contextClickable
void setContextClickable(boolean);
定義此視圖是否對上下文單擊事件作出反應。
- android:defaultFocusHighlightEnabled
void setDefaultFocusHighlightEnabled(boolean);
在其背景中未定義R.attr.state_focused時,獲得焦點時是否應使用默認焦點效果。
- android:drawingCacheQuality
void setDrawingCacheQuality(int);
在啟用繪圖緩存時定義繪圖緩存的質量。
默認值為auto。
隨著API 11中硬件加速渲染,視圖繪制緩存基本上已經過時,不推薦使用。
View.DRAWING_CACHE_QUALITY_LOW(xml:low)
低質量;
View.DRAWING_CACHE_QUALITY_HIGH(xml:high)
高質量;
View.DRAWING_CACHE_QUALITY_AUTO(xml:auto)
自動;
- android:duplicateParentState
void setDuplicateParentStateEnabled(boolean);
當此屬性設置為true時,視圖將從其直接父級而不是從其自身獲取其可繪制狀態(聚焦,按下等)。
如,點擊父控件,子控件會有點擊效果但是不觸發點擊事件。
- android:elevation
void setElevation(float);
z軸的高度。
- android:fadeScrollbars
void setScrollbarFadingEnabled(boolean);
在不使用時是否淡出滾動條。
- android:fadingEdge
void setHorizontalFadingEdgeEnabled(boolean);
void setVerticalFadingEdgeEnabled(boolean);
api>=14被忽略,使用requiresFadingEdge代替
- android:fadingEdgeLength
void setFadingEdgeLength(int);
設置邊框漸變的長度。
- android:filterTouchesWhenObscured
void setFilterTouchesWhenObscured(boolean);
指定當視圖的窗口被另一個可見窗口遮擋時是否過濾觸摸。
設置為true時,只要在視圖窗口上方出現Toast,對話框或其他窗口,視圖就不會接收到后續的觸摸事件。
- android:fitsSystemWindows
void setFitsSystemWindows(boolean);
用于根據系統窗口(如狀態欄)調整視圖布局。
如果為true,則調整此視圖的填充以為系統窗口留出空間。
如果為false,狀態欄等會遮擋住界面。僅在此視圖處于非嵌入式Activity時才會生效。
- android:focusable
void setFocusable(boolean);
void setFocusable(int);
控制視圖是否可以獲得焦點。
默認情況下,是auto,它允許框架確定用戶是否可以將焦點移動到視圖。
通過將此屬性設置為true,允許視圖獲得焦點。
通過將其設置為false,視圖將不會成為焦點。
此值不會影響直接調用View.requestFocus(),無論此視圖如何,都會請求焦點。
只會影響焦點導航嘗試移動焦點的位置。
- android:focusableInTouchMode
void setFocusableInTouchMode(boolean);
用于控制視圖在觸摸模式下是否可以獲得焦點。
如果為true,則該視圖在單擊時可以獲得焦點,并且如果單擊另一個沒有將此屬性設置為true的視圖,則可以繼續保持焦點。
- android:focusedByDefault
void setFocusedByDefault(boolean);
此視圖是否為默認焦點視圖。
每個鍵盤導航集群只能有一個視圖可以將此屬性設置為true。
- android:forceHasOverlappingRendering
void forceHasOverlappingRendering(boolean);
此視圖是否具有在繪制時可能重疊的元素。
會覆蓋hasOverlappingRendering()方法的返回值。
- android:foreground
void setForeground(Drawable);
設置前景,可以做遮罩等。
- android:foregroundGravity
void setForegroundGravity(int);
前景的Gravity。
- android:foregroundTint
void setForegroundTintList(ColorStateList);
將設置的顏色和原來的前景進行一個疊加。
根據foregroundTintMode來疊加
- android:foregroundTintMode
void setForegroundTintMode(PorterDuff.Mode);
前景疊加模式PorterDuff.Mode
- android:hapticFeedbackEnabled
void setHapticFeedbackEnabled(boolean);
用于控制視圖是否應為單擊,長按等事件啟用觸覺反饋。
- android:importantForAccessibility
void setImportantForAccessibility(int);
控制View是否能啟用無障礙功能,輔助功能服務可能會忽略此屬性并對視圖樹中的所有視圖進行操作。
View.IMPORTANT_FOR_ACCESSIBILITY_AUTO(xml:auto)
系統決定;
View.IMPORTANT_FOR_ACCESSIBILITY_YES(xml:yes)
啟用;
View.IMPORTANT_FOR_ACCESSIBILITY_NO(xml:no)
不啟用;
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS(xml:noHideDescendants)
不啟用;
- android:importantForAutofill
void setImportantForAutofill(int);
提示Android系統是否應將與此視圖關聯的視圖節點包含在用于自動填充目的的視圖結構中。
View.IMPORTANT_FOR_AUTOFILL_AUTO(xml:auto)
系統決定;
View.IMPORTANT_FOR_AUTOFILL_YES(xml:yes)
包含,并循環判斷子控件;
View.IMPORTANT_FOR_AUTOFILL_NO(xml:no)
不包含,并循環判斷子控件;
View.IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS(xml:yesExcludeDescendants)
包含,不判斷子控件;
View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS(xml:noExcludeDescendants)
不包含,不判斷子控件;
- android:isScrollContainer
void setScrollContainer(boolean);
如果視圖將用作滾動容器,則設置此項,這意味著可以調整其大小以縮小其整個窗口,以便為輸入方法提供空間。
如果未設置,當"scrollbars"設置了垂直滾動條,則默認值為true,否則為false。
- android:keepScreenOn
void setKeepScreenOn(boolean);
控制屏幕常亮。
- android:keyboardNavigationCluster
void setKeyboardNavigationCluster(boolean);
此視圖是否是鍵盤導航集群的根節點(不太懂)。
- android:labelFor
void setLabelFor(int);
指定視圖的id,此視圖用作可訪問性標簽。
例如,UI中EditText之前的TextView通常指定EditText中包含的信息。 因此,TextView是EditText的標簽。
- android:layerType
void setLayerType(int, Paint);
指定支持此視圖的圖層類型。
默認值為none。
View.LAYER_TYPE_NONE(xml:none)
不設置圖層;
View.LAYER_TYPE_SOFTWARE(xml:software)
使用軟件圖層;
View.LAYER_TYPE_HARDWARE(xml:hardware)
使用硬件圖層;
- android:layoutDirection
void setLayoutDirection(int);
定義布局繪圖的方向。
如從右到左的布局使用在諸如阿拉伯語、希伯來語等環境中。 此屬性的默認值為inherit。
View.LAYOUT_DIRECTION_LTR(xml:ltr)
從左到右,“en-US”中使用的方向;
View.LAYOUT_DIRECTION_RTL(xml:rtl)
從右到左;
View.LAYOUT_DIRECTION_INHERIT(xml:inherit)
從父控件繼承;
View.LAYOUT_DIRECTION_LOCALE(xml:locale)
使用“en-US”,即從左到右;
- android:longClickable
void setLongClickable(boolean);
是否響應長按事件。
- android:minHeight
void setMinimumHeight(int);
定義視圖的最小高度。
不保證將能夠達到此最小高度(例如,如果其父布局的高度更小)。
- android:minWidth
void setMinimumWidth(int);
定義視圖的最小寬度。
不保證將能夠實現此最小寬度(例如,如果其父布局的寬度更小)。
- android:nestedScrollingEnabled
void setNestedScrollingEnabled(boolean);
是否允許嵌套滑動。
- android:nextClusterForward
void setNextClusterForwardId(int);
定義下一個鍵盤導航集群。
如果該引用引用的視圖不存在或者是不可見的層次結構的一部分,則在訪問引用時將產生RuntimeException。(這個也不太明白)
- android:nextFocusDown
void setNextFocusDownId(int);
當點down鍵時,哪個控件將獲得焦點。
- android:nextFocusForward
void setNextFocusForwardId(int);
設置指定視圖獲得下一個焦點。
- android:nextFocusLeft
void setNextFocusLeftId(int);
當點left鍵時,哪個控件將獲得焦點。
- android:nextFocusRight
void setNextFocusRightId(int);
當點right鍵時,哪個控件將獲得焦點。
- android:nextFocusUp
void setNextFocusUpId(int);
當點up鍵時,哪個控件將獲得焦點。
- android:onClick
void setOnClickListener(OnClickListener);
單擊視圖時要調用的此View上下文中方法的名稱。
此名稱必須對應于一個public方法,該方法只接受一個View類型的參數。
例如,如果指定android:onClick ="sayHello",則必須聲明上下文(通常是Activity)的public void sayHello(View v)方法。
- android:outlineProvider
void setOutlineProvider(ViewOutlineProvider);
設置輪廓。
null(xml:none)
不設置;
ViewOutlineProvider.BACKGROUND(xml:background)
根據背景設置;
ViewOutlineProvider.BOUNDS(xml:bounds)
根據View設置;
ViewOutlineProvider.PADDED_BOUNDS(xml:paddedBounds)
根據View設置,除去padding部分;
- android:overScrollMode
void setOverScrollMode(int);
一般支持可滾動的布局或控件,如SrollView、ListView、RecycleView、ViewPager等,設置當滾動到邊界時的效果。
View.OVER_SCROLL_NEVER(xml:never)
不觸發;
View.OVER_SCROLL_IF_CONTENT_SCROLLS(xml:ifContentScrolls)
當內容可滾動時觸發;
View.OVER_SCROLL_ALWAYS(xml:always)
都觸發;
- android:padding
void setPadding(int, int, int, int);
void setPaddingRelative(int, int, int, int);
上下左右內邊距。
- android:paddingBottom
void setPadding(int, int, int, int);
void setPaddingRelative(int, int, int, int);
底部內邊距。
- android:paddingEnd
void setPaddingRelative(int, int, int, int);
末尾部分內邊距。
- android:paddingHorizontal
void setPadding(int, int, int, int);
void setPaddingRelative(int, int, int, int);
左右內邊距。
- android:paddingLeft
void setPadding(int, int, int, int);
左邊內邊距。
- android:paddingRight
void setPadding(int, int, int, int);
右邊內邊距。
- android:paddingStart
void setPaddingRelative(int, int, int, int);
開頭部分內邊距。
- android:paddingTop
void setPadding(int, int, int, int);
void setPaddingRelative(int, int, int, int);
頂部內邊距。
- android:paddingVertical
void setPadding(int, int, int, int);
void setPaddingRelative(int, int, int, int);
上下內邊距。
- android:pointerIcon
void setPointerIcon(PointerIcon);
鼠標圖標。
PointerIcon.TYPE_NULL(xml:none)
不可見;
PointerIcon.TYPE_ARROW(xml:arrow)
默認箭頭;
PointerIcon.TYPE_CONTEXT_MENU(xml:context_menu)
指示上下文菜單;
PointerIcon.TYPE_HAND(xml:hand)
伸出食指的手;
PointerIcon.TYPE_HELP(xml:help)
幫助;
PointerIcon.TYPE_WAIT(xml:wait)
等待;
PointerIcon.TYPE_CELL(xml:cell)
細胞和網格;
PointerIcon.TYPE_CROSSHAIR(xml:crosshair)
十字準線,表明發現一個位置;
PointerIcon.TYPE_TEXT(xml:text)
工字型,表示文本輸入;
PointerIcon.TYPE_VERTICAL_TEXT(xml:vertical_text)
用于垂直文本的90度旋轉工字型的指針圖標;
PointerIcon.TYPE_ALIAS(xml:alias)
創建快捷方式;
PointerIcon.TYPE_COPY(xml:copy)
拖放;
PointerIcon.TYPE_NO_DROP(xml:no_drop)
不可以拖拽到當前位置;
PointerIcon.TYPE_ALL_SCROLL(xml:all_scroll)
四向箭頭,表示滾動所有方向;
PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW(xml:horizontal_double_arrow)
水平雙箭頭,表明水平調整大小;
PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW(xml:vertical_double_arrow)
垂直雙箭頭,表明垂直調整大小;
PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW(xml:top_right_diagonal_double_arrow)
對角雙箭頭,從右上角到左下角。 指示自由形式調整大小;
PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW(xml:top_left_diagonal_double_arrow)
對角雙箭頭,從左上角到右下角。 指示自由形式調整大小;
PointerIcon.TYPE_ZOOM_IN(xml:zoom_in)
放大;
PointerIcon.TYPE_ZOOM_OUT(xml:zoom_out)
縮小;
PointerIcon.TYPE_GRAB(xml:grab)
抓取;
PointerIcon.TYPE_GRABBING(xml:grabbing)
正在抓取
- android:requiresFadingEdge
void setHorizontalFadingEdgeEnabled(boolean);
void setVerticalFadingEdgeEnabled(boolean);
定義滾動時哪些邊應該褪色。
- android:rotation
void setRotation(float);
旋轉視圖,以度為單位。
- android:rotationX
void setRotationX(float);
圍繞x軸旋轉視圖,以度為單位。
- android:rotationY
void setRotationY(float);
繞y軸旋轉視圖,以度為單位。
- android:saveEnabled
void setSaveEnabled(boolean);
如果為false,則在凍結該視圖時不會保存任何狀態。
默認值為true,允許保存視圖,但是也必須為其分配ID以保存其狀態。
將此設置為false僅禁用此視圖的狀態,不會禁用子控件。
- android:scaleX
void setScaleX(float);
x方向視圖的縮放。
- android:scaleY
void setScaleY(float);
y方向視圖的縮放。
- android:scrollIndicators
void setScrollIndicators(int);
void setScrollIndicators(int, int);
定義可以滾動視圖時應顯示的滾動指示符。
- android:scrollX
void setScrollX(int);
初始水平滾動偏移,以像素為單位。
- android:scrollY
void setScrollY(int);
初始垂直滾動偏移,以像素為單位。
- android:scrollbarAlwaysDrawHorizontalTrack
//沒有相應的代碼接口
是否應始終繪制水平滾動條軌道。
- android:scrollbarAlwaysDrawVerticalTrack
//沒有相應的代碼接口
是否應始終繪制垂直滾動條軌道。
- android:scrollbarDefaultDelayBeforeFade
void setScrollBarDefaultDelayBeforeFade(int);
定義滾動條在淡出之前等待的延遲(以毫秒為單位)。
- android:scrollbarFadeDuration
void setScrollBarFadeDuration(int);
定義滾動條淡出所用的時間(以毫秒為單位)。
- android:scrollbarSize
void setScrollBarSize(int);
設置垂直滾動條的寬度和水平滾動條的高度。
- android:scrollbarStyle
void setScrollBarStyle(int);
控制滾動條樣式和位置。
View.SCROLLBARS_INSIDE_OVERLAY(xml:insideOverlay)
在padding區域內并且覆蓋在view上;
View.SCROLLBARS_INSIDE_INSET(xml:insideInset)
在padding區域內并且插入在view后面;
View.SCROLLBARS_OUTSIDE_OVERLAY(xml:outsideOverlay)
在padding區域外并且覆蓋在view上;
View.SCROLLBARS_OUTSIDE_INSET(xml:outsideInset)
在padding區域外并且插入在view后面;
- android:scrollbarThumbHorizontal
//沒有相應的代碼接口
水平滾動條thumb圖片。
- android:scrollbarThumbVertical
//沒有相應的代碼接口
垂直滾動條thumb圖片。
- android:scrollbarTrackHorizontal
//沒有相應的代碼接口
水平滾動條軌道圖片。
- android:scrollbarTrackVertical
//沒有相應的代碼接口
垂直滾動條軌道圖片。
- android:scrollbars
void setVerticalScrollBarEnabled(boolean);
void setHorizontalScrollBarEnabled(boolean);
定義滾動時應顯示哪些滾動條。
- android:soundEffectsEnabled
void setSoundEffectsEnabled(boolean);
按鍵提示音。
- android:stateListAnimator
void setStateListAnimator(StateListAnimator);
狀態(焦點,按下等)改變時的動畫效果。
- android:tag
void setTag(Object);
為此視圖提供包含String的標記,可以使用View.getTag()獲得tag或使用View.findViewWithTag()搜索。
- android:textAlignment
void setTextAlignment(int);
文本的對齊方式。
View.TEXT_ALIGNMENT_INHERIT(xml:inherit)
默認;
View.TEXT_ALIGNMENT_GRAVITY(xml:gravity)
相對于每個段落的文本方向;
View.TEXT_ALIGNMENT_TEXT_START(xml:textStart)
對其段落開頭;
View.TEXT_ALIGNMENT_TEXT_END(xml:textEnd)
對其段落末尾;
View.TEXT_ALIGNMENT_CENTER(xml:center)
段落居中;
View.TEXT_ALIGNMENT_VIEW_START(xml:viewStart)
對其視圖開頭,相對于layoutDirection;
View.TEXT_ALIGNMENT_VIEW_END(xml:viewEnd)
對其視圖末尾,相對于layoutDirection;
- android:textDirection
void setTextDirection(int);
定義文本的方向。
View.TEXT_DIRECTION_INHERIT(xml:inherit)
默認;
View.TEXT_DIRECTION_FIRST_STRONG(xml:firstStrong)
第一個強制方向字符決定段落方向。 如果沒有強制方向字符,則段落方向是視圖的已解析布局方向;
View.TEXT_DIRECTION_ANY_RTL(xml:anyRtl)
如果它包含任何強制為RTL字符則段落方向是RTL,如果它包含任何強制為LTR字符則段落方向是LTR。 如果兩者都沒有,則段落方向是視圖已解析布局方向;
View.TEXT_DIRECTION_LTR(xml:ltr)
段落方向從左到右;
View.TEXT_DIRECTION_RTL(xml:rtl)
段落方向從右到左;
View.TEXT_DIRECTION_LOCALE(xml:locale)
系統判斷;
View.TEXT_DIRECTION_FIRST_STRONG_LTR(xml:firstStrongLtr)
第一個強制方向字符決定段落方向。 如果沒有強制方向性,則段落方向為LTR;
View.TEXT_DIRECTION_FIRST_STRONG_RTL(xml:firstStrongRtl)
第一個強制方向字符決定段落方向。 如果沒有強制方向性,則段落方向為LTR;
- android:theme
//沒有相應的代碼接口
//在View實例化時可傳入
指定主題。
設置主題時,將使用以指定資源為主題的上下文對視圖進行填充。
- android:tooltipText
void setTooltipText(CharSequence);
定義在懸停或長按時在小彈出窗口中顯示的文本。
- android:transformPivotX
void setPivotX(float);
x軸上的位置,視圖將圍繞該位置旋轉和縮放。
- android:transformPivotY
void setPivotY(float);
y軸上的位置,視圖將圍繞該位置旋轉和縮放。
- android:transitionName
void setTransitionName(String);
- android:translationX
void setTranslationX(float);
x軸偏移量。
- android:translationY
void setTranslationY(float);
y軸偏移量。
- android:translationZ
void setTranslationZ(float);
z軸偏移量。
- android:verticalScrollbarPosition
view.setVerticalScrollbarPosition(int);
確定垂直滾動條應放在哪一側。
View.SCROLLBAR_POSITION_DEFAULT(xml:defaultPosition)
系統默認;
View.SCROLLBAR_POSITION_LEFT(xml:left)
左邊;
`View.SCROLLBAR_POSITION_RIGHT(xml:right)右邊;
- android:visibility
void setVisibility(int visibility);
view可見狀態。
View.VISIBLE(xml:visible)
可見;
View.INVISIBLE(xml:invisible)
不可見但占用空間;
View.GONE(xml:gone)
不可見也不占用空間;
然后更新了一下插件,支持了View類中的屬性
<View
android:id="@+id/v1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:accessibilityLiveRegion="polite"
android:accessibilityTraversalAfter="@id/v1"
android:accessibilityTraversalBefore="@id/v1"
android:alpha="0.5"
android:autofillHints="password"
android:background="@color/colorAccent"
android:backgroundTint="@color/colorPrimary"
android:backgroundTintMode="src_in"
android:clickable="true"
android:contentDescription="@string/app_name"
android:contextClickable="true"
android:defaultFocusHighlightEnabled="true"
android:drawingCacheQuality="high"
android:duplicateParentState="true"
android:elevation="2dp"
android:fadeScrollbars="true"
android:fadingEdge="vertical|horizontal"
android:fadingEdgeLength="3dp"
android:filterTouchesWhenObscured="true"
android:fitsSystemWindows="true"
android:focusable="auto"
android:focusableInTouchMode="true"
android:focusedByDefault="true"
android:forceHasOverlappingRendering="true"
android:foreground="@mipmap/ic_launcher"
android:foregroundGravity="clip_horizontal"
android:foregroundTint="@color/colorPrimaryDark"
android:foregroundTintMode="src_in" />
<View
android:id="@+id/v2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hapticFeedbackEnabled="true"
android:importantForAccessibility="noHideDescendants"
android:importantForAutofill="yesExcludeDescendants"
android:isScrollContainer="true"
android:keepScreenOn="true"
android:keyboardNavigationCluster="true"
android:labelFor="@id/v1"
android:layerType="hardware"
android:layoutDirection="rtl"
android:longClickable="true"
android:minHeight="12dp"
android:minWidth="11dp"
android:nestedScrollingEnabled="true"
android:nextClusterForward="@id/v2"
android:nextFocusDown="@id/v2"
android:nextFocusForward="@id/v2"
android:nextFocusLeft="@id/v2"
android:nextFocusRight="@id/v2"
android:nextFocusUp="@id/v2"
android:onClick="as"
android:outlineProvider="none"
android:overScrollMode="ifContentScrolls"
android:padding="12dp"
android:paddingBottom="23dp"
android:paddingEnd="22dp"
android:paddingHorizontal="11dp"
android:paddingLeft="22dp"
android:paddingRight="11dp"
android:paddingStart="33dp"
android:paddingTop="44dp"
android:paddingVertical="55dp"
android:pointerIcon="zoom_in" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:requiresFadingEdge="horizontal"
android:rotation="90"
android:rotationX="20"
android:rotationY="45"
android:saveEnabled="true"
android:scaleX="0.6"
android:scaleY="0.5"
android:scrollIndicators="right"
android:scrollX="12dp"
android:scrollY="22dp"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarDefaultDelayBeforeFade="12"
android:scrollbarFadeDuration="70"
android:scrollbarSize="12dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbHorizontal="@drawable/ic_launcher_background"
android:scrollbarThumbVertical="@drawable/ic_launcher_background"
android:scrollbarTrackHorizontal="@drawable/ic_launcher_background"
android:scrollbarTrackVertical="@color/colorPrimary"
android:scrollbars="none"
android:soundEffectsEnabled="true"
android:stateListAnimator="@drawable/ic_launcher_background"
android:tag="tag"
android:textAlignment="viewStart"
android:textDirection="locale"
android:theme="@style/AlertDialog.AppCompat"
android:tooltipText="@string/app_name"
android:transformPivotX="1dp"
android:transformPivotY="12dp"
android:transitionName="@string/appbar_scrolling_view_behavior"
android:translationX="12dp"
android:translationY="5dp"
android:translationZ="22dp"
android:verticalScrollbarPosition="left"
android:visibility="visible" />
轉換之后
view {
id = R.id.v1
accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_POLITE
accessibilityTraversalAfter = R.id.v1
accessibilityTraversalBefore = R.id.v1
alpha = 0.5f
setAutofillHints(View.AUTOFILL_HINT_PASSWORD)
backgroundColor = resources.getColor(R.color.colorAccent)
backgroundTintList = resources.getColorStateList(R.color.colorPrimary)
backgroundTintMode = PorterDuff.Mode.SRC_IN
isClickable = true
contentDescription = resources.getString(R.string.app_name)
isContextClickable = true
defaultFocusHighlightEnabled = true
drawingCacheQuality = View.DRAWING_CACHE_QUALITY_HIGH
isDuplicateParentStateEnabled = true
elevation = dip(2).toFloat()
isScrollbarFadingEnabled = true
isVerticalFadingEdgeEnabled = true
isHorizontalFadingEdgeEnabled = true
setFadingEdgeLength(dip(3))
filterTouchesWhenObscured = true
fitsSystemWindows = true
//android:focusable = auto //Auto is default
isFocusableInTouchMode = true
isFocusedByDefault = true
forceHasOverlappingRendering(true)
foreground = resources.getDrawable(R.mipmap.ic_launcher)
foregroundGravity = Gravity.CLIP_HORIZONTAL
foregroundTintList = resources.getColorStateList(R.color.colorPrimaryDark)
foregroundTintMode = PorterDuff.Mode.SRC_IN
}
view {
id = R.id.v2
isHapticFeedbackEnabled = true
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
importantForAutofill = View.IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS
isScrollContainer = true
keepScreenOn = true
isKeyboardNavigationCluster = true
labelFor = R.id.v2
setLayerType(View.LAYER_TYPE_HARDWARE, null)
layoutDirection = View.LAYOUT_DIRECTION_RTL
isLongClickable = true
minimumHeight = dip(12)
minimumWidth = dip(11)
isNestedScrollingEnabled = true
nextClusterForwardId = R.id.v2
nextFocusDownId = R.id.v2
nextFocusForwardId = R.id.v2
nextFocusLeftId = R.id.v2
nextFocusRightId = R.id.v2
nextFocusUpId = R.id.v2
setOnClickListener {
//as()
}
outlineProvider = ViewOutlineProvider.BACKGROUND
overScrollMode = View.OVER_SCROLL_IF_CONTENT_SCROLLS
padding = dip(12)
bottomPadding = dip(23)
setPaddingRelative(paddingStart, paddingTop, dip(22), paddingBottom)
horizontalPadding = dip(11)
leftPadding = dip(22)
rightPadding = dip(11)
setPaddingRelative(dip(33), paddingTop, paddingEnd, paddingBottom)
topPadding = dip(44)
verticalPadding = dip(55)
pointerIcon = PointerIcon.getSystemIcon(context, PointerIcon.TYPE_ZOOM_IN)
}
themedView(R.style.AlertDialog_AppCompat) {
isVerticalFadingEdgeEnabled = false
isHorizontalFadingEdgeEnabled = true
rotation = 90.0f
rotationX = 20.0f
rotationY = 45.0f
isSaveEnabled = true
scaleX = 0.6f
scaleY = 0.5f
scrollIndicators = View.SCROLL_INDICATOR_RIGHT
scrollX = dip(12)
scrollY = dip(22)
//android:scrollbarAlwaysDrawHorizontalTrack = true //Can not be set by code
//android:scrollbarAlwaysDrawVerticalTrack = true //Can not be set by code
scrollBarDefaultDelayBeforeFade = 12
scrollBarFadeDuration = 70
scrollBarSize = dip(12)
scrollBarStyle = View.SCROLLBARS_OUTSIDE_OVERLAY
//android:scrollbarThumbHorizontal = @drawable/ic_launcher_background //Can not be set by code
//android:scrollbarThumbVertical = @drawable/ic_launcher_background //Can not be set by code
//android:scrollbarTrackHorizontal = @drawable/ic_launcher_background //Can not be set by code
//android:scrollbarTrackVertical = @color/colorPrimary //Can not be set by code
isVerticalScrollBarEnabled = false
isHorizontalScrollBarEnabled = false
isSoundEffectsEnabled = true
stateListAnimator = AnimatorInflater.loadStateListAnimator(context, R.drawable.ic_launcher_background)
tag = "tag"
textAlignment = View.TEXT_ALIGNMENT_VIEW_START
textDirection = View.TEXT_DIRECTION_LOCALE
tooltipText = resources.getString(R.string.app_name)
pivotX = dip(1).toFloat()
pivotY = dip(12).toFloat()
transitionName = resources.getString(R.string.appbar_scrolling_view_behavior)
translationX = dip(12).toFloat()
translationY = dip(5).toFloat()
translationZ = dip(22).toFloat()
verticalScrollbarPosition = View.SCROLLBAR_POSITION_LEFT
visibility = View.VISIBLE
}.lparams(width = matchParent, height = matchParent)