您的位置:首页 > 移动开发 > Android开发

Android中View属性大全

2015-08-03 17:10 671 查看

android:alpha setAlpha(float) 设置alpha属性 0-1 完全透明到不透明

android:backgroud 背景

android:clickable 是否回应点击事件

android:contentDescription setContentDescription(CharSequence) 定义文字,简要介绍该视图内容。

android:drawingCacheQuality setDrawingCacheQuality(int)

设置绘图时半透明质量。有以下值可设置:auto(默认,由框架决定)/high(高质量,使用较高的颜色深度,消耗更多的内存)/low(低质量,使用较低的颜色深度,但是用更少的内存)。

android:duplicateParentState

如果设置此属性,将直接从父容器中获取绘图状态(光标,按下等)。 见下面代码部分,注意根据目前测试情况仅仅是获取绘图状态,而没有获取事件,也就是你点一下LinearLayout时Button有被点击的效果,但是不执行点击事件。





android:fadeScrollbars
setScrollbarFadingEnabled(boolean)

设置滚动条的自动隐藏,即不滚动的时候隐藏

android:fadingEdgeLength getVerticalFadingEdgeLength()

设置 边框渐变的长度。

android:filterTouchesWhenObscured setFilterTouchesWhenObscured(boolean)

view所在窗口被其它可见窗口遮住时,是否过滤触摸事件。

android:fitsSystemWindows setFitsSystemWindows(boolean)

设置布局调整时是否考虑系统窗口

android:focusablesetFocusable(boolean)
设置是否获得焦点。若有requestFocus()被调用时,后者优先处理。注意在表单中想设置某一个如 EditText获取焦点,光设置这个是不行的,需要将这个EditText前面的focusable都设置为false才行。在Touch模式下获取焦点需要设置focusableInTouchMode为true。

android:focusableInTouchModesetFocusableInTouchMode(boolean)
设置在Touch模式下View是否能取得焦点。

android:hapticFeedbackEnabledsetHapticFeedbackEnabled(boolean)
设置长按时是否接受其他触摸反馈事件。

android:idsetId(int)
android:importantForAccessibilitysetImportantForAccessibility(int)
android:isScrollContainersetScrollContainer(boolean)
设置当前View为滚动容器。这里没有测试出效果来,ListView/ GridView/ ScrollView根本就不用设置这个属性,而EdidText设置android:scrollbars也能出滚动条。

android:keepScreenOnsetKeepScreenOn(boolean)
android:keepScreenOn View在可见的情况下是否保持唤醒状态。

android:layerTypesetLayerType(int,Paint)
android:longClickablesetLongClickable(boolean)
设置时候支持长按事件

android:minHeightsetMinimumHeight(int)
设置视图最小高度

android:minWidthsetMinimumWidth(int)
设置视图的最小高度

android:nextFocusLeftsetNextFocusLeftId(int)
android:nextFocusRightsetNextFocusRightId(int)
android:nextFocusUpsetNextFocusUpId(int)
android:nextFocusDownsetNextFocusDownId(int)
android:nextFocusForwardsetNextFocusForwardId(int)
设置下方指定视图获得下一个焦点。焦点移动是基于一个在给定方向查找最近邻居的算法。如果指定视图不存在,移动焦点时将报运行时错误。可以设置imeOptions

android:onClick
指定点击后要执行的方法 这个方法在java代码里完成 例如buttonClick(View view)

android:padding

android:paddingBottom

android:paddingLeft

android:paddingRight

android:paddingTop
setPadding(int,int,int,int)
设置边距

android:requiresFadingEdgesetVerticalFadingEdgeEnabled(boolean)
定义是否绘制竖直方向的滚动条 默认是不绘制

android:rotationsetRotation(float)
定义view的选择角度,API Level 11

android:rotationXsetRotationX(float)
android:rotationYsetRotationY(float)
选择的基准点 API Level 11

android:saveEnabledsetSaveEnabled(boolean)
设置是否在窗口冻结时(如旋转屏幕)保存View的数据,默认为true,但是前提是你需要设置id才能自动保存

android:scaleXsetScaleX(float)
android:scaleYsetScaleY(float)
设置缩放的基准点
android:scrollY android:scrollX

以像素为单位竖直和水平方向的移动距离

android:scrollbarAlwaysDrawHorizontalTrack
android:scrollbarAlwaysDrawVerticalTrack
设置是否始终显示水平和竖直方向的滚动条

android:scrollbarDefaultDelayBeforeFadesetScrollBarDefaultDelayBeforeFade(int)
设置N毫秒后开始淡化,以毫秒为单位。

android:scrollbarFadeDurationsetScrollBarFadeDuration(int)
设置滚动条淡出效果(从有到慢慢的变淡直至消失)时间,以毫秒为单位。Android2.2中滚动条滚动完之后会消失,再滚动又会出来,在1.5、1.6版本里面会一直显示着。

android:scrollbarSizesetScrollBarSize(int)
设置滚动条的宽度

android:scrollbarStylesetScrollBarStyle(int)

android:scrollbarThumbHorizontal
android:scrollbarThumbVertical
设置水平滚动条的图片或者颜色

android:scrollbarTrackHorizontal
android:scrollbarTrackVertical
设置滚动条背景(轨迹)的drawable注意直接设置颜色值如”android:color/white”将得出很难看的效果,甚至都不理解这个属性了,这里可以参见ApiDemos里res/drawable/ scrollbar_vertical_thumb.xml和scrollbar_vertical_track.xml,设置代码为:android:scrollbarTrackVertical ="@drawable/scrollbar_vertical_track"

android:scrollbars
设置滚动条显示。none(隐藏),horizontal(水平),vertical(垂直)

android:soundEffectsEnabledsetSoundEffectsEnabled(boolean)
设置点击或触摸时是否有声音效果

android:tag
设置标签

android:transformPivotXsetPivotX(float)
android:transformPivotYsetPivotY(float)
设置缩放和选择的点

android:visibilitysetVisibility(int)
设置可见性

本文转载自:/article/11826038.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: