zoukankan      html  css  js  c++  java
  • 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>

    效果图:

  • 相关阅读:
    一个C++的unit库
    一篇关于如何组织unit tests的文章,很有趣
    web开发者的checklist
    用了story point就一定agile了吗?
    C#中如何用Windows Management Instrumentation (WMI)得到系统信息
    Windows下C++的同步机制的演变
    Sysinternals自动更新的工具SyncTools
    什么情况下要替换C++自带的new和delete
    VS2012插件:可视化TFS代码版本历史
    Quattro发布自助手机广告产品
  • 原文地址:https://www.cnblogs.com/Engi-xx/p/6306270.html
Copyright © 2011-2022 走看看