zoukankan      html  css  js  c++  java
  • 关于UI的TextView的及其子类一些方法

    完成联系我功能(about us)--加入邮箱,手机号。

    <TextView

    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:text="邮件是191651196@qq.com,电话是13204508077"
    android:autoLink="email|phone"/>



    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchColumns="1">


    //填写信息
    <TableRow>
    <TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="用户名:"
    android:textSize="16sp"/>
    <EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="请填写登录账号"//隐藏文字,提示
    android:selectAllOnFocus="true"/>//选择焦点输入
    </TableRow>

    //填写密码
    <EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="numberPassword"/>

    引申相关方法:

    android:inputType="number"//输入数字,赋值后,输入法定性为数字

    android:inputType="date"//输入日期,赋值后,输入法定性为日期

    android:inputType="phone"//输入数据,赋值后,输入法定性为数字,输入格式字数控制


    <!-- 设置文字颜色、大小,并使用阴影 -->
    <TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="测试文字"
    android:shadowColor="#00f"
    android:shadowDx="10.0"
    android:shadowDy="8.0"
    android:shadowRadius="3.0"
    android:textColor="#f00"
    android:textSize="18pt"/>


    <!-- 设置中间省略,所有字母大写 -->
    <TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:text="我爱Java我aaaJava"
    android:ellipsize="middle"//超范围中间省略
    android:textAllCaps="true"/>//大小写


    <!-- 设置字号为20pt,文本框结尾处绘制图片 -->
    <TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="我爱Java"
    android:textSize="20pt"
    android:drawableEnd="@drawable/cs"/>//插入图片

    <?xml version="1.0" encoding="UTF-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 指定按钮按下时的图片 -->
    <item android:state_pressed="true"
    android:drawable="@drawable/red"
    />
    <!-- 指定按钮松开时的图片 -->
    <item android:state_pressed="false"
    android:drawable="@drawable/purple"

    />
    </selector>

    按键选择响应

    RadioGroup rg;
    TextView show;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // 获取界面上rg、show两个组件
    rg = (RadioGroup) findViewById(R.id.rg);
    show = (TextView) findViewById(R.id.show);
    // 为RadioGroup组件的OnCheckedChange事件绑定事件监听器
    rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
    {
    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId)
    {
    // 根据用户勾选的单选按钮来动态改变tip字符串的值
    String tip = checkedId == R.id.male ?
    "您的性别是男人": "您的性别是女人";
    // 修改show组件中的文本
    show.setText(tip);
    }
    });
    }

    //按键选择响应

  • 相关阅读:
    POJ-1035 Spell checker---字符串处理
    hdu-3572 Task Schedule---最大流判断满流+dinic算法
    BZOJ4826: [Hnoi2017]影魔
    BZOJ4825: [Hnoi2017]单旋
    BZOJ3504: [Cqoi2014]危桥
    BZOJ4407: 于神之怒加强版
    BZOJ2818: Gcd
    BZOJ4542: [Hnoi2016]大数
    BZOJ4540: [Hnoi2016]序列
    BZOJ4537: [Hnoi2016]最小公倍数
  • 原文地址:https://www.cnblogs.com/yhc04161120/p/4790883.html
Copyright © 2011-2022 走看看