首页 > 代码库 > android: button 属性
android: button 属性
代码中常用属性:
Button bt=new Buttion(Context context);
setClickable(boolean clickable) | 设置按钮是否允许点击。 clickable=true:允许点击 clickable=false:禁止点击 |
setBackgroundResource(int resid) | 通过资源文件设置背景色。 resid:资源xml文件ID。 按钮默认背景为:android.R.drawable.btn_default |
setText(CharSequence text) | 设置按钮显示文字。 |
setTextColor(int color) | 设置按钮显示文字的颜色。 color可以使用系统Color常量,例如 Color.BLACK等。 |
setOnClickListener(OnClickListener l) | 设置按钮点击事件 |
xml中常用属性:
android:layout_width=""---控件宽
android:layout_height=""---控件高
android:layout_weight=""---控件权重
android:text=""---控件上的文本内容
android:onClick="doClick"---点击此控件时调用的方法---方法名称为:doClick
android:drawableTop=""---在Button组件上放置图片
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。