Android:UI设计 常用控件

TextView

<TextView
    android:id="@+id/first_txetview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
 
    android:gravity="center"
    android:textSize="24sp"
    android:textColor="#00ff00"

    android:text="This is first TextView!"
/>

android:layout_widthandroid:layout_height 指定控件的宽度和高度,可选值有三个:match_parentfill_parentwrap_contentmatch_parentfill_parent 相似,以父布局大小决定控件大小;wrap_content 以控件内容决定控件大小。

android:gravity 指定文字对齐方式,可选值 top、bottomrightleftcenter 等,可以用 “ |” 同时指定多个值。

android:textSizeandroid:textColor 指定文字大小和颜色。

Button

<Button
    android:id="@+id/first_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
 
    android:textAllCaps="false"
 
    android:text="This is first Button!"
/>

android:textAllCaps=”false” 禁用属性,不对英文字母进行大写转换。

EditText

<EditText
    android:id="@+id/editText"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
 
    android:hint="Please input something"
    android:maxLines="2"
/>

android:hint 指定一段提示性文本,当在输入框输入内容时,这段文字消失。

android:maxLines 指定最大显示行数,超过后文本会向上滑动。

其他一些控件:
android:srcImageView 指定一张图片,用于显示。

    原文作者:被被的安卓编程之路
    原文地址: https://www.jianshu.com/p/af1227a8cf65
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞