android widget 布局,Android Widget Attributes——View

最近因为想着重新把这个插件捡起来,把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);

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);

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类中的属性

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" />

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" />

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)

52fa04a21fbf

xml1.png

52fa04a21fbf

anko1.png

52fa04a21fbf

xml2.png

52fa04a21fbf

anko2.png

52fa04a21fbf

xml3.png

52fa04a21fbf

anko3.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值