zoukankan      html  css  js  c++  java
  • 【安卓3】基本控件

    Activity用于存放各个显示控件,是Android的基本组成

    Activity常用方法:

    Activity类常用方法

    方法

    描述

    view findViewById ( int id )

    根据组件的id取得组件对象

    setEnabled(boolean enabled)

    设置是否可编辑

    setFocusable(boolean focusable)

    设置是否默认取得焦点

    setProgress(int progress)

    设置ProgressBar的进度

    setSecondaryProgress(int secondaryProgress)

    设置第二进度条的进度

    Window getWindow()

    取得一个Window对象

    setContendView ( int  layoutResId )

    设置布局文件,设置显示文件

    setContendView (View view )

    设置显示组件

    配置属性名称

    对应方法

    描述

    android: text

    public final void setText(CharSequence text)

    定义组件的显示文字

    android: maxLength

    public void setFilter(InputFilter[] filters)

    设置组件最大允许长度

    android: textColor

    public void setTextColor(ColorStateList colors)

    设置组件的文本颜色

    android: textSize

    public void setTextSize(float size)

    设置显示的文字大小

    android: textStyle

    设置文字显示的样式、粗体、斜体等

    android: selectAllOnFocus

    public void setAllOnFocus (boolean setAllOnFocus)

    默认选中并获得焦点

    android: password

    public final void setTransformationMethod

    (TransformationMethod method)

    按密文方式显示文本信息

    设置字体风格和大小

           (android: textStyle)——》{正常(normal)、粗体(bold)、斜体(italic)}

           字体大小的单位:

                  px(像素)、dip(依赖于设备的像素)、sp(带比例的像素)、pt(点)、in(英尺)、mm(毫米)

           android: id= ” @id/id值”                             //设置id值

           android: text=”**”                                       //定义显示文字

            android: layout_width="wrap_content"      //组件宽度为文字宽度

           android: layout_height="wrap_content"      //组件宽度为文字高度

    TextView(文本显示框)

           android: maxLength=”6”                              //允许最大字符数

           android: textColor=”#0FF00”                        //文字颜色

           android: textSize=”50px”                             //文字大小

           android: textStyle=”bold”                             //文字样式

           android: password=”true”                            //是否以密文方式显示

           android: layout_margin=”10px”                    //外边距

           android: backgroud=”@drawable/图片名称”     //背景

           getText().toString()                               //获得控件的文本内容

           setText()                                          //设置控件的文本内容

    Button (按钮)

    EditText(编辑框)

             android: password=””                  //是否以密文方式显示

           android: numeric=”integer”             //只能输入数字

           android: hint=”**”                         //水印

           android: enabled=”false”                //设置是否可用,false不能用

    RadioButton(单选按钮)

           嵌入到RadioGroup中实现单选效果

             android: checkedButton=”radio的id值 ”;

           int getCheckedRadioButtonId( );           //获得被选中的单选按钮的id

    CheckBox(复选框)

             android: checked=”true”;               //设置默认选中

             CheckBox(Context context)             //实例化CheckBox组件

           void setChecked(boolean checked)      //设置默认选中

    ImageView(图片)

           android: maxHeight=” ”;                //定义图片的最大高度

           android: maxWidth=” ”;                 //定义图片的最大宽度

           android: src=” ”;                           //定义显示图片的ID

    ImageButton(图片按钮)

    *重复属性省略*

  • 相关阅读:
    Yield Usage Understanding
    Deadclock on calling async methond
    How to generate file name according to datetime in bat command
    Run Unit API Testing Which Was Distributed To Multiple Test Agents
    druid的关键参数+数据库连接池运行原理
    修改idea打开新窗口的默认配置
    spring boot -thymeleaf-url
    @pathvariable和@RequestParam的区别
    spring boot -thymeleaf-域对象操作
    spring boot -thymeleaf-遍历list和map
  • 原文地址:https://www.cnblogs.com/leelee/p/6860435.html
Copyright © 2011-2022 走看看