Android 基础UI

 

1.button

<Button

    android:background="@color/colorAccent" //背景颜色

    android:textSize="10sp"   //字体大小,以sp为单位

    android:textColor="#000"   //字体颜色,以RGB为单位

    android:text="按钮"    //在按钮上显示的文字

    android:id="@+id/btn_show"   //按钮的id

//按钮的 宽/高 度,wrap_content(随内容的大小)、match_parent(占满父容器的宽度)

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

 

2.TextView

不能输入内容,只能显示内容

<TextView

    android:id="@+id/Text_show"

    android:text="文本框"

    android:textColor="@color/colorPrimary"

    android:textSize="10sp"

    android:background="@color/colorPrimary"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

3.editView

可以输入内容,能显示提示信息,在输入内容后提示信息会消失但清除输入的内容提示会再次显示

<EditText

    android:id="@+id/Edi_show"

    android:hint="编辑框"   //显示提示

    android:textColorHint="@color/colorPrimary" //对提示信息设置字体颜色

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

 

4.Checkbox

可以设置多个,可以选中或取消。

<CheckBox

    android:text="多选框"

    android:textColor="@color/colorAccent"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

5.RadioButton

单独使用这个组件不能有单选的效果,必须配合<RadioGroup></RadioGroup>标签一起使用

<RadioButton

    android:id="@+id/radio"

    android:text="单选按钮"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

6.Spinner

下拉列可以定制更复杂的选项列表

<Spinner

    android:entries="@array/data"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content">

</Spinner>

下拉列表选项,这里的只是静态设置,一般都是放在values/strings.xml文件中

<string-array name="data">

    <item>下拉框1</item>

    <item>下拉框2</item>

    <item>下拉框3</item>

    <item>下拉框4</item>

    <item>下拉框5</item>

    <item>下拉框6</item>

</string-array>

效果图:

原文地址:https://www.cnblogs.com/Engi-xx/p/6306270.html