千峰Android_Day02

来源:互联网 发布:单片机两个舵机正反转 编辑:程序博客网 时间:2024/06/02 01:09

2016年1月18日(千峰实训第二天)
控件篇:

按钮:

      <Button        android:id="@+id/btn"       android:layout_width="60dp"       android:layout_height="40dp"       android:layout_alignParentRight="true"       android:layout_below="@+id/img"       android:text="赞"       android:textSize="20sp"        android:layout_marginRight="20dp"       />

图片:

     <ImageView        android:contentDescription="@string/app_name"       android:id="@+id/img"       android:layout_width="500dp"       android:layout_height="200dp"       android:scaleType="fitXY"       android:src="@drawable/a1"       android:layout_toRightOf="@+id/icon"       android:layout_below="@+id/emotion"       android:layout_marginRight="20dp"       />

文本:

   <TextView        android:id="@+id/emotion"       android:layout_width="match_parent"       android:layout_height="wrap_content"       android:text="哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦"       android:layout_toRightOf="@+id/icon"       android:layout_below="@+id/name"       android:layout_marginRight="20dp"       />

可编辑文本:

   <TextView        android:id="@+id/emotion"       android:layout_width="match_parent"       android:layout_height="wrap_content"       android:text="哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦"       android:layout_toRightOf="@+id/icon"       android:layout_below="@+id/name"       android:layout_marginRight="20dp"       />

String str = edit_count.getText().toString().trim();
//获得可编辑文本内容
Toast.makeText(MainActivity.this, str, Toast.LENGTH_LONG).show();
// 在虚拟机打印,相当于syso

anim_rorate = AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotate); // 初始化可执行性动作

img.startAnimation(anim_shake);// 开始执行

setonclicklistener // 设置事件监听
findviewbyid // 赋内存 关联layout中id
//线式布局 orientation //设置水平 竖直
SRC 导入图片
hint //提示语
textsize// 设置字体大小 单位sp
centerHorizontal//水平居中
marginleft //距离左边距离 right右 top上 bottom 下
layout_torightof //在XX右 above 上 below 下
alignparentleft //在左边 top 上 below下

1)fill_parent
设置一个构件的布局为fill_parent将强制性地使构件扩展,以填充布局单元内尽可能多的空间

2) wrap_content
设置一个视图的尺寸为wrap_content将强制性地使视图扩展以显示全部内容

3)match_parent
Android2.2中match_parent和fill_parent是一个意思 .两个参数意思一样,match_parent更贴切

未完待续。

0 0
原创粉丝点击