Android Studio [TextView]
MainAcitvity
package com.xdw.secondapp; import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button; public class MainActivity extends AppCompatActivity { Button mBtnTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBtnTextView=findViewById(R.id.Text_view1);
mBtnTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//跳转到TextView演示界面
Intent intent =new Intent(MainActivity.this,TextViewActivity.class);
startActivity(intent);
}
});
}
}
TextViewAcitvity
package com.xdw.secondapp; import android.graphics.Paint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView; public class TextViewActivity extends AppCompatActivity {
private TextView mTv4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text_view);
mTv4=findViewById(R.id.tv_4);
mTv4.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);//中划线
mTv4.getPaint().setAntiAlias(true);//去除锯齿
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="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"
tools:context=".MainActivity"> <Button
android:id="@+id/Text_view1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"/> </LinearLayout>
activity_text_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="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"
tools:context=".TextViewActivity"
android:orientation="vertical"> <TextView
android:id="@+id/tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="瑞哥在奔跑"
android:textColor="#000000"
android:textSize="24sp" /> <TextView
android:id="@+id/tv_2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ellipsize="end"
android:maxLines="1"
android:text="瑞哥在奔跑"
android:textColor="#000000"
android:textSize="24sp" /> <TextView
android:id="@+id/tv_3"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:drawableRight="@drawable/timm"
android:drawablePadding="5dp"
android:text="筛选"
android:textColor="#000000"
android:textSize="24sp"
/>
<TextView
android:id="@+id/tv_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="瑞哥在奔跑"
android:textColor="#000000"
android:textSize="24sp"
android:layout_marginTop="10dp"/>
</LinearLayout>
我学到的:
定义mTv4
mTv4.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);//中划线
mTv4.getPaint().setAntiAlias(true);//去除锯齿
android:text="TextView"//输出文字
定义mBtnTextView
mBtnTextView=findViewById(R.id.Text_view1);
mBtnTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//跳转到TextView演示界面
Intent intent =new Intent(MainActivity.this,TextViewActivity.class);
startActivity(intent);
}
});
//跳转
结果:
Android Studio [TextView]的更多相关文章
- android textview字体加粗 Android studio最新水平居中和垂直居中
android textview字体加粗 Android studio最新水平居中和垂直居中 Android中字体加粗在xml文件中使用android:textStyle=”bold”但是不能将中文设 ...
- Android Studio 之 TextView基础
•引言 在开始本节内容前,先要介绍下几个单位: dp(dip) : device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关 一般我们为了支持 ...
- Android Studio 如何在TextView中设置图标并按需调整图标大小
•任务 相信大家对这张图片都不陌生,没错,就是 QQ动态 向我们展示的界面. 如何实现呢? •添加文字并放入图标 新建一个 Activity,取名为 QQ,Android Studio 自动为我们生成 ...
- Android Studio配置 AndroidAnnotations——Hi_博客 Android App 开发笔记
以前用Eclicps 用习惯了现在 想学学 用Android Studio 两天的钻研终于 在我电脑上装了一个Android Studio 并完成了AndroidAnnotations 的配置. An ...
- android studio你可能忽视的细节——启动白屏?drawable和mipmap出现的意义?这里都有!!!
android studio用了很久了,也不知道各位小伙伴有没有还在用eclipse的,如果还有,楼主真心推荐转到android studio来吧,毕竟亲儿子,你会知道除了启动速度稍微慢些,你找不到一 ...
- Android开发的小技巧,在Android Studio中使用Designtime Layout Attributes
在编写xml文件时,为了预览效果,经常会使用默认填上一些内容,比如TextView时,随便写上一个text <TextView ... android:text="Name:" ...
- 【android 开 发 】 - Android studio 下 NDK Jni 开发 简单例子
Android 开发了一段时间,一方面 ,感觉不留下点什么.有点对不起自己, 另一方面,好记性不如烂笔头,为了往后可以回头来看看,就当做是笔记,便决定开始写博客.废话不多说 ! 今天想搞一搞 ndk ...
- Android开发自学笔记(Android Studio) 目录
开发环境如下: 操作系统:Windows 10 Pro IDE:Android Studio 1.3.X 或更高版本 其它请参见文章说明. 1. 环境搭建 1.1 (番外)AndroidStudio常 ...
- Android开发自学笔记(Android Studio)—4.界面编程与View组件简单介绍
一.引言 Android应用开发最重要的一份内容就是界面的开发,无论你程序包含的内容多么优秀,如若没有一个良好的用户交互界面,最终也只是会被用户所遗弃.Android SDK提供了大量功能丰富的UI组 ...
随机推荐
- nuget cli常用命令简介
起因:使用nuget,但是部分同事用的mac,不能用vs的包管理器查看私有nuget库里面的包,所以,就总结了几个常用的 nuget cli 命令,方便全平台使用nuget 废话不多,直入主题 准备: ...
- 水果机抽奖(CocosCreator)
推荐阅读: 我的CSDN 我的博客园 QQ群:704621321 一.前言 在前面给大家分享了大转盘的抽奖方式,这是现在游戏使用较多的一种抽奖方式,今天给大家介绍另一抽奖方式--水果 ...
- 使用WPF为Powershell程序制作GUI界面
1. 使用Xaml创建应用界面 打开visual studio,创建一个新的项目,在已安装模板中选择Visual C# →Wpf应用. 完成创建后,我们得到如下图所示的应用界面. wpf界面是基于xa ...
- spring-boot整合dubbo启动demo
参考资料: https://docs.spring.io/spring-boot/docs/2.1.7.RELEASE/reference/html/ https://github.com/apach ...
- 安装Python及各种包/库——没有网络的电脑上
我们做项目时可能会遇到,一些电脑只能联内网或者无法联网,这种情况怎样在电脑上安装Python及各种第三方包/库呢? 1.首先,在有网络的电脑上在python官网下载好python安装包,地址:http ...
- Python 基础(四)
open函数 open(name[,mode[,buffering[,encoding]]]) mode(访问模式): -1 : r(只读) w(只写,若文件存在则覆盖) a(追加) rb(二进制只读 ...
- CF - 652 D Nested Segments
题目传送门 题解: 可以将所有线段按照左端点优先小,其次右端点优先大进行排序. 然后对于第 i 条线段来说, 那么第 i+1 ---- n 的线段左端点都一定在第i条线段的右边, 接下来就需要知道 i ...
- CF1072A Palindromic Twist 思维
Palindromic Twist time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- hdu1255 覆盖的面积(线段树面积交)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1255 面积交与面积并相似相比回了面积并,面积交一定会有思路,当然就是cover标记大于等于两次时. 但 ...
- codeforces 919C Seat Arrangements 思维模拟
C. Seat Arrangements time limit per test 1 second memory limit per test 256 megabytes input standard ...

