Android UI控件之TextView
2016-12-02 15:25
337 查看
TextView
前言:
TextView主要用于字体显示,其继承于View类,TextView控件的功能时想用户显示文本的内容,但不允许编辑。
而其子类EditView允许用户进行编辑。
以下为TextView常用的属性以及对应方法进行说明,最后在附上一个简易Demo。
常用属性:
以上就是关于TextView 的属性、有兴趣的朋友自行写一个Demo体验下。
这里先看下显示效果:
主Activity.java如下:
主.xml文件如下:
该控件讲解到此结束!!!
源工程地址如下:
https://github.com/DSLAndroid/UI_Application_03
本资源来自单胜凌!!!
Android靠自学!!!
祝各位IT人士早日取得成功!!!
前言:
TextView主要用于字体显示,其继承于View类,TextView控件的功能时想用户显示文本的内容,但不允许编辑。
而其子类EditView允许用户进行编辑。
以下为TextView常用的属性以及对应方法进行说明,最后在附上一个简易Demo。
常用属性:
以上就是关于TextView 的属性、有兴趣的朋友自行写一个Demo体验下。
这里先看下显示效果:
主Activity.java如下:
package com.dsl.ui_application_03; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity { TextView text1; TextView text2; TextView text3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initUI(); } /** * 控件初始化 */ public void initUI() { text1 = (TextView)findViewById(R.id.text1); text2 = (TextView)findViewById(R.id.text2); text2 = (TextView)findViewById(R.id.text3); MyTextlistener my = new MyTextlistener(); text1.setOnClickListener(my); text2.setOnClickListener(my); text3.setOnClickListener(my); } /** * 自定义监听类,该类实现了View类 */ class MyTextlistener implements View.OnClickListener{ @Override public void onClick(View v) { switch (v.getId()) { case R.id.text1://改变第一行字体显示 text1.setText("第一行!"); break; case R.id.text2://改变第二行字体显示 text1.setText("第二行!"); break; case R.id.text3://改变第三行字体显示 text1.setText("第三行!"); break; } } } }
主.xml文件如下:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.dsl.ui_application_03.MainActivity"> <TextView android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> <TextView android:id="@+id/text2" android:layout_marginTop="30dp" android:layout_below="@id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorAccent" android:textSize="20dp" android:text="你们好!我是单胜凌!" /> <TextView android:id="@+id/text3" android:layout_marginTop="30dp" android:layout_below="@id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorPrimary" android:textSize="50dp" android:text="Hello Android!" /> </RelativeLayout>
该控件讲解到此结束!!!
源工程地址如下:
https://github.com/DSLAndroid/UI_Application_03
本资源来自单胜凌!!!
Android靠自学!!!
祝各位IT人士早日取得成功!!!
相关文章推荐
- android_常用UI控件_01_TextView3_点击打开新的activity
- Day4.2--Android高级UI控件之AutoCompleteTextView的使用
- [Android新手学习笔记11]-UI控件之TextView
- Android UI 控件之TextView
- 【Android UI控件】EditText属性大全,TextView属性大全
- Android基础UI控件之AutoCompleteTextView
- android 关于线程更新UI控件,包括gridview,textview,imageview等
- Android学习-常见的UI控件 TextView、EditText和ImageView
- Android UI 之TextView控件中可选择的属性列表,开发中经常用到的
- Android UI 之TextView控件中可选择的属性列表,开发中经常用到的
- Day3.2--Android简单UI控件之TextView的高级使用--SpannableString的使用
- 一起Talk Android吧(第五十九回:Android中UI控件之TextView)
- Android UI 之TextView控件属性列表
- Android UI控件自动提示控件(AutoCompleteTextView)
- Android UI 设计——TextView 控件
- Android UI系统控件进阶(三)—自动完成文本控件AutoCompleteTextView详解及属性
- android UI - 简单控件textView Button ImageView ImageButton
- Android 开发基础篇——UI——基础控件(TextView、Button、EditText)
- AndroidUI控件之TextView及其子类
- Android UI控件系列:TextView(文本框)