发表于: 2016-06-30 23:07:46

1 703


今天了解三个常用的控件,分别是TextView,button和editText。

textView的作用就是在界面上显示文字的。使用方法为:

<TextView

android:id=“@+id/text_view”

android:layout_width=“match_parent”      //文字宽度控制::

android :layout_height="match_parent"     //文字高度控制

android :gravity="center"                           //控制文字排布

android :text="THIS IS TEXTVIEW"/>      //要输入的文字

除了这些以外,ViewText还有其他属性,比如 android:textColor设置文本颜色,android:textStyle设置字形等等。

第二个控件是button,也就是按钮。

它的使用方法是:

<Button

android:id="@+id/button

android:layout_width=“match_parent”      //文字宽度控制::

android :layout_height="match_parent"     //文字高度控制

android:text="Button"                                //按键名字叫button

</LinearLayout>

此外,我们还可以为button添加一个点击事件注册的一个监听器。

EditText,它的功能就是用户可以在空间里面输入编辑内容。常用的软件qq,微信等等都要用到这个。

其实这些控件使用方法大致一样,先使用id来定义,再使用layout的width和height来控制控件的大小。当然每个控件都有自己的特性,功能也不一样。

明天的任务:学掌握其他的几个控件的功能和使用。如imageView,progressBar,AlertDioalog.



返回列表 返回列表
评论

    分享到