安卓开发 UI入门

布局的类型

线性布局 LinearLayout *** 

  垂直显示 vertical

  水平显示 horizontal 

  文本适应 wrap_content

  填充父窗体 match_parent

  权重 layout_weight = "1"

相对布局 RelativelLayout *** 

  layout_centerInParent

  layout_centerVertical

  layout_centerHorizontal

  layout_above

  layout_below

  layout_toLeftOf

  layout_toRightOf

  layouy_alignParentTop / Left / Right / Bottom

  layout_alignTop / Bottom / Left / Right

  layout_marginTop / Bottom / Left / Right

  paddingTop / Bottom / Left / Right

帧布局 FrameLayout **

  foreground 

  foregroundGravity

表格布局 TableLayout

  stretchColumns 拉伸

  shrinkColumns 收缩

  collapseColumns 隐藏 不显示 不占空间

  layout_column  显示在第几列

  layout_span  占据几行

绝对布局 AbsoluteLayout (GoogleAPI弃用)

  layout_x

  layout_y

常用控件

TextView

  text

  textcolor

  textSize

  textStyle

  height

  width

  maxLength

  password

  gravity  设置文本位置, 如设置成"center"

  phoneNumber

  layout_height

  layout_width

 *** layout_width 和 width的区别

  带"layout"前缀的属性通常是相对父控件而言的 而width height相对于控件本身

EditText

  hint

  lines

  maxLines

  minLines

  password

  phoneNumber 

  scrollHorizontally 是否出现横拉条

  capitalize 设置首字母大写

  editable

Button

  1.匿名类调用方法

  2.绑定点击事件

  3.Activity实现OnClickListener接口

  4.实现OnClickListener接口并重写Onclick方法 (不常用)

Button Btn = (Button)findViewById(R.id.btn);
Btn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Toast.makeText(MainActivity.this, "点击了Btn", Toast.LENGTH_LONG).show();
    }
});    

RadioButton 单选按钮 与RadioGroup配合使用 

  checked // true为选中

ImageView 

  background  背景 随界面拉伸

  src 前景 以原图大小显示

    

  

猜你喜欢

转载自www.cnblogs.com/Draymonder/p/9839709.html