天天看点

笔记 - Android - 3.控件属性

android:控件

    <textview/>:普通文本标签

    <edittext/>:输入框

        > android:hint:在输入框控件中起提示作用;

        > android:lines:限定输入框的可视行数

        > android:maxlength:限定输入框中的可输入字符长度;

        > android:inputtype:指定输入框的类型

            >> textpassword:指定输入框类型为密码框

            >> ......

    <button/>:按钮

        > android:onclick:指定该按钮的单击事件方法名

    <checkbox/>:复选框

        > android:checked:布尔值,指示复选框初始状态

··控件通用属性

    android:id:每个控件的唯一标识符;

    android:text:控件中显示的文本字符串;

    android:textcolor:控件中显示的文字的颜色;

    android:textsize:控件中字体的大小,单位为sp;

··控件通用布局属性

    android:layout_width:控件的宽度

        取值:

            fill_parent:填充父容器

            match_parent:填充父容器,与fill_parent相同

            wrap_content:包裹内容,表示控件宽度随内容的宽度变化而变化

    android:layout_height:控件的高度

            同宽度

    android:layout_above:该控件位置在指定控件的上面

    android:layout_below:该控件位置在指定控件的下面

    android:layout_toleftof:该控件位置在指定控件的左边

    android:layout_torightof:该控件位置在指定控件的右边

    android:layout_margin:上下左右四边外边距

    android:layout_margintop:上外边距

    android:layout_marginright:右外边距

    android:layout_marginbottom:下外边距

    android:layout_marginleft:左外边距

    android:layout_padding:上下左右四边内边距

    android:layout_paddingtop:上内边距

    android:layout_paddingright:右内边距

    android:layout_paddingbottom:下内边距

    android:layout_paddingleft:左内边距

继续阅读