文本框和文本编辑框

  1. 文本框(TextView)
    2.1 简介
    TextView直接继承View,作用就是在界面上显示文本(类似于Swing中的JLabel),同时它还是EditText、Button两个UI组件类的父类。
    另外Android关闭了它的文字编辑功能,如果想编辑内容,则可以使用EditText。
    2.2 TextView常用属性
    2.2.1 text
    2.2.2 autoLink
    2.2.3 singleLine(已过时,现在应为:android:lines)
    2.2.4 lines
    2.2.5 minLines
    2.2.6 textColor
    2.2.7 textSize
    2.2.8 textStyle
    字体风格粗体、斜体
    2.2.9 backgroud
    设置背景,可以是颜色或图片
    2.2.10 drawableXX
    设置文本的icon
    2.2.11 ellipsize 当文字长度超过textview宽度时的显示方式
    android:ellipsize=”start” 省略号显示在开头 “…pedia”
    android:ellipsize=”end” 省略号显示在结尾 “encyc…”
    android:ellipsize=”middle” 省略号显示在中间 “en…dia”
    android:ellipsize=”marquee” 以横向滚动方式显示(另外还需要设置其它三个属性,否则不滚动,即必须让该控件获得焦点)

  2. 编辑框(EditText)
    3.1 简介
    EditText和TextView非常相似,它与TextView共用了绝大总分XML属性和文法,
    二者最大区别在于:EditText可以接受用户输入。
    3.2 常用属性
    3.2.1 inputType
    它是EditText组件最重要的属性,它相当于HTML中标签的type属性,用于EditText指定输入组件的类型。
    常用取值有:number|numberPassword|date|phone
    3.2.2 hint:提示字符信息

Andriod简易计算机的加减乘除
activity_main.xml
"1.0" encoding="utf-8"?>
"http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:rowCount="7"
    android:columnCount="4"
    tools:context=".MainActivity">

"@+id/main_et_result"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_columnSpan="4"
      />

  

你可能感兴趣的:(文本框和文本编辑框)