Android_常用控件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39019735/article/details/73086949

几天没写博客了今天来写篇文章记录一下这几天学到的技术:Android常用的控件

TextView(文本视图):

//TextView所呈现的文字
android:text="我爱Java"
//文字颜色
android:textColor="#f00"
//文字尺寸
android:textSize="20pt"

//文本框结尾处绘制图片  
android:drawableEnd="@drawable/ic_launcher"

//不管内容多长,单行显示
android:singleLine="true"
//文字过长时,中间部分省略
android:ellipsize="middle"

//全部字母大写
android:textAllCaps="true"

//若文字为email或者电话号码,以特殊形式呈现
android:autoLink="email|phone"

//文字为密码,以点代替
android:password="true"

//文字阴影相关
android:shadowColor="#0000ff"
android:shadowDx="10.0"
android:shadowDy="8.0"
android:shadowRadius="3.0"

//指定背景图案

android:background="@drawable/bg_border"


EditText(文本编辑器):

android:hint="请输入数字!"//设置显示在空间上的提示信息
android:numeric="integer"//设置只能输入整数,如果是小数则是:decimal
android:singleLine="true"//设置单行输入,一旦设置为true,则文字不会自动换行。
android:password="true"//设置只能输入密码
android:textColor = "#ff8c00"//字体颜色
android:textStyle="bold"//字体,bold, italic, bolditalic
android:textSize="20dip"//大小
android:capitalize = "characters"//以大写字母写
android:textAlign="center"//EditText没有这个属性,但TextView有,居中
android:textColorHighlight="#cccccc"//被选中文字的底色,默认为蓝色
android:textColorHint="#ffff00"//设置提示信息文字的颜色,默认为灰色android:textScaleX="1.5"//控制字与字之间的间距
android:typeface="monospace"//字型,normal, sans, serif, monospace
android:background="@null"//背景,这里没有,指透明
android:layout_weight="1"//权重,控制控件之间的地位,在控制控件显示的大小时蛮有用的。
android:textAppearance="?android:attr/textAppearanceLargeInverse"//文字外观
android:layout_gravity="center_vertical"//设置控件显示的位置:默认top,这里居中显示,还有bottom


RadioButton(单选框):

android:checkedButtion=""---默认被选中按钮

扫描二维码关注公众号,回复: 6120937 查看本文章

android:orientation=""---单选按钮排列的方式

RadioButton必须用Radiogroup包起来,不然不会实现单选效果


ImageView(图片视图):

android:adjustViewBounds:是否保持宽高比。需要与maxWidthMaxHeight一起使用,否则单独使用没有效果。

android:cropToPadding是否截取指定区域用空白代替。单独设置无效果,需要与scrollY一起使用

android:maxHeight:设置View的最大高度,单独使用无效,需要与setAdjustViewBounds一起使用

android:scaleType

matrix:用矩阵来绘图

fitXY:伸图片(不按比例)以填充View的宽高

fitStart:按比例拉伸图片,拉伸后图片的高度为View的高度,且显示在View的左边

fitCenter:按比例拉伸图片,拉伸后图片的高度为View的高度,且显示在View的中间

fitEnd:按比例拉伸图片,拉伸后图片的高度为View的高度,且显示在View的右边

center:按原图大小显示图片,但图片宽高大于View的宽高时,截图图片中间部分显示

centerCrop:按比例放大原图直至等于某边View的宽高显示

centerInside:当原图宽高或等于View的宽高时,按原图大小居中显示;反之将原图缩放至View的宽高居中显示





猜你喜欢

转载自blog.csdn.net/qq_39019735/article/details/73086949
今日推荐