一、常用控件:

文本控件:– TextView – EditText 

按钮控件: – Button – ImageButton 

状态开关按钮:– ToggleButton 

单选与复选按钮:– CheckBox和RadioButton 

图片控件:– ImageView 

时钟控件:– AnalogClock – DigitalClock

日期与时间选择控件: – DatePicker – TimePicker


1.插入图片 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:src="@mipmap/pic"/>

2.插入可编辑文本框:
//控件id
android:id = "@+id/bjwbk"  

//宽度与高度
android:layout_width="wrap_content"  //或者match_parent
android:layout_height="wrap_content"  //或者match_parent

//文本文字 
android:text="文字" 

//文本提示内容
android:hint="请输入手机号"

//字体大小
android:textSize="30dp"  

//字体颜色
android:textColor="#ffffff"  

//字体格式
android:textStyle="normal"  //normal 正常, bold 加粗, italic 斜体

//文本显示位置
android:gravity="center"  //指定文字的对齐方式: top、bottom、left、right、center 等

//是否只在一行内显示全部内容
android:singleLine="true"  

//输入内容设置为password类型
android:password="true"  //输入的内容会变成······

//输入内容设置为phoneNumber类型
android:phoneNumber="true"  //只能输入数字

//设定光标为显示/隐藏
android:cursorVisible = "false" //true或者false,默认为true显示

/>

3.插入文本框:

//控件id
android:id = "@+id/wbk" 

//宽度与高度
android:layout_width="wrap_content"  //或者"match_parent"
android:layout_height="wrap_content"  //或者"match_parent"

//文字 
android:text="文本文字" 

//字体大小
android:textSize="24dp"  // dp为单位

//字体颜色
android:textColor="#0000FF"  

//字体格式
android:textStyle="normal"  //normal 正常, bold 加粗, italic 斜体

//文本显示位置
android:gravity="center"  //指定文字的对齐方式: top、bottom、left、right、center 等

//是否只在一行内显示全部内容
android:singleLine="true"  //true或者false,默认为false  
/>

4.插入按钮:
android:onClick="login" 
android:text="删除按钮" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" />

5.CheckBox  复选框按钮:

 android:id="@+id/box1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="选择内容"
 android:textColor="#ffffff"
 android:checked="true"/>


二、常用布局:

相对布局 – RelativeLayout

    ---相对其他控件进行布局,默认相对父控件。
    
    使控件居中的两种方法:
    
    1.通过gravity,使当前根布局下的所有孩子控件相对于当前的布局居中显示。
    android:gravity="center_horizontal"
    
    2.通过layout_gravity,当前控件相对于父控件显示的位置
             android:layout_gravity="center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/textView" />
    
    ListView以列表的形式展示具体内容
             android:id="@+id/lv"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

线性布局 – LinearLayout 

    ---水平或垂直的顺序排列布局

表格布局 – TableLayout

    ---采用行、列的形式来管理控件,通过添加TableRow、
    其他组件来控制表格的行数和列数
    每向TableLayout中添加一个TableRow就代表一行
    每向TableRow中添加一个一个子组件就表示一列。

网格布局 – GridLayout

    ---与TableLayout类似,把容器分为rows × columns个网格,每个网格可以放置一个控件。

帧布局 – FrameLayout


    ---为每个加入其中的控件创建一个空白的区域(称为一帧),
    每个子控件占据一帧,这些帧会根据gravity属性执行自动对齐
    后面控件将会覆盖或重叠在前面的控件上。


绝对布局 – AbsoluteLayout


    ---采用绝对坐标进行布局定位。


 

更多相关文章

  1. Android使用Recycler View实现瀑布流效果
  2. Android-EditText属性大全
  3. Kotlin Anko 使用相对布局 RelativeLayout
  4. Android开发中ImageView的scaletype属性用法分析
  5. 【Android笔记】(2)ButtonClickPic
  6. ActionBar的使用
  7. 用android studio写一个简单并且bug奇多的计算器
  8. android alertdialog布局 dialog布局
  9. android播放网络或者本地视频(截取某帧做封面)VideoView原生控件

随机推荐

  1. Android中BroadcastReceiver的使用
  2. android greenDAO
  3. android控件之EditText
  4. android webview夜间模式javascript代码
  5. Android SQLite数据库存储实现
  6. Android之Intent和常用Action
  7. Android调用系统自带的文件管理器进行文
  8. Android中使用Bezier曲线
  9. android编译错误--/usr/bin/ld: cannot f
  10. Android 学习 之 TextView结合SpannableS