android中控件属性往往,android控件属性总结

一、以android:开头的属性

属性

作用

示例(省略前面部分)

autoLink

设置是否文本为URL/email/phone等,文本显示为可点击的链接

none/web/email/phone/map/all

background

设置背景颜色或图片

"@null"透明

drawableBottom

在text的下方插入一个drawable,如图片;若指定一个颜色,则将text的背景设为该颜色,同时和background使用时覆盖后者

类似也有drawableLeft/drawableRight/drawableTop

drawablePadding

设置text与drawable的间隔,可设置为负数,单独使用没有效果

editable

只接受数字

true/false

elipsize

设置当文字过长时,该控件该如何显示["start":省略号显示在开头;"end":省略号显示在结尾;"middle":省略号显示在中间;"marquee":以跑马灯的方式显示(动画横向移动)]。

start

gravity

设置文本内容在控件中的位置

center/left/right/top/bottom

hint

设置显示在空间上的提示信息

"输入内容"

numeric

输入数字

maxLength

限制显示的文本长度,超出部分不显示

5

minLines

设置文本的最小行数

5

password

设置只能输入密码

true/false

phoneNumber

输入电话号码

singleLine

设置单行输入一旦设置为true,则文字不会自动换行

true/false

textColorHighlight

被选中字体的底色,默认是蓝色

#ffff00

textColorHint

设置提示信息文字的颜色

#ffff00

textScaleX

控制字与字间的间距

1.5

textSize

字体大小

12sp

textStyle

字体类型

bold/italic/bolditalic

二、ImageView控件部分属性

(1) android:adjustViewBounds属性

android:adjustViewBounds: 调整插入的图片与ImageView控件设置的长宽高度,即当ImageView一边固定,另一边为wrap_content/0dp时才会有意义!

(2) 图片旋转方法

旋转bitmap的方法(效率较低)

Bitmap bitmap = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_launcher)).getBitmap();

Matrix matrix = new Matrix();

matrix.setRotate(90);

Bitmap new = Bitmap.create(bitmap,0,bitmap.getWidth(),0,bitmap.getHeight(),matrix);

image.setBitmapResource(bitmap);

若程序不断获取新的bitmap重新设置给ImageView的话,那么bitmap在不断旋转,该方法要做好内存回收,即bitmap.recycle()

android:rotation:ImageView自带的旋转方法

(1) 可以通过在xml中设置ImageView的属性来实现

android:rotation="90"

(2)动态调用

image.setPivotX(image.getWidth()/2);

image.setPivotY(image.getHeight()/2);//支点在图片中心

image.setRotation(90);

使用旋转动画

可以使用ImageView配合属性动画实现,如

rotateImage.animate().rotation(90)

或者普通动画

Animation rotateAnimation = new RotateAnimation(lastAngle, progress, Animation.RELATIVE_TO_SELF,

0.5f, Animation.RELATIVE_TO_SELF, 1);

rotateAnimation.setFillAfter(true);

rotateAnimation.setDuration(50);

rotateAnimation.setRepeatCount(0);

rotateAnimation.setInterpolator(new LinearInterpolator());

rotateImage.startAnimation(rotateAnimation);

其他博客看到的

Matrix matrix=new Matrix();

rotateImage.setScaleType(ScaleType.MATRIX); //required

matrix.postRotate((float) progress, pivotX, pivotY);

rotateImage.setImageMatrix(matrix);

三、EditText控件去掉下划线

解决方案:

android:background="@color/white"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值