开发工具的安装

选择使用Android Studio进行开发,Android Studio 是谷歌推出的一个Android集成开发工具,基于IntelliJ IDEA. 类似 Eclipse ADT,Android Studio 提供了集成的 Android 开发工具用于开发和调试。

在此附上大佬的安装教程:Android Studio安装教程

UI组件

1 布局管理器

  • 线性布局(LinearLayout)
  • 相对布局(RelativeLayout)

1.1 LinearLayout

常用属性:

  • id
  • layout_width
    • match_parent 匹配父控件
    • wrap_content 填充文字
  • layout_height
  • background
  • layout_margin
  • layout_padding
  • orientation
<?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"
android:orientation="vertical"
tools:context=".MainActivity"> <LinearLayout
android:id="@+id/ll_1"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#8BC34A"
android:orientation="vertical"
android:padding="20dp"> <View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#565555"/> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#8B634A"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:gravity="bottom"> <View
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#FFC107"
android:layout_weight="1"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/> </LinearLayout> </LinearLayout>

1.2 RelativeLayout

layout_

  • toLeftOf
  • toRightOf
  • alignBottom
  • alignParentBottom
  • below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"> <View
android:id="@+id/view_1"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#4600108D" /> <View
android:id="@+id/view_2"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#FF5722"
android:layout_toRightOf="@id/view_1"/> <View
android:id="@+id/view_3"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#46BCC719"
android:layout_below="@id/view_2"/> <LinearLayout
android:id="@+id/ll_1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="@id/view_3"
android:background="#888888"
android:orientation="horizontal"
android:padding="15dp"> <View
android:layout_width="100dp"
android:layout_height="match_parent"
android:background="#465456"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:padding="15dp"> <View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#888888"/> </RelativeLayout> </LinearLayout> </RelativeLayout>

TextView控件

创建按钮新建一个空白活动

在activity_main.xml中创建一个按钮用于点击跳转

<Button
android:id="@+id/bt_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮"/>

在MainActivity.java中添加bt_1的点击事件使其跳转到TextViewActivity

public class MainActivity extends AppCompatActivity {

    private Button mbtn;

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mbtn = findViewById(R.id.bt_1);
mbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//跳转到演示界面
Intent intent = new Intent(MainActivity.this,TextViewActivity.class);
startActivity(intent);
}
});
}
}

创建一个新的TextViewActivity,在activity_text_view.xml中创建TextView控件并实现以下功能

  • 文字在一行中显示并标注未现实完全

activity_text_view.xml

<TextView
android:id="@+id/tv_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="学习Android的第一天"
android:textSize="50sp"
android:layout_marginTop="10dp"/>

效果显示图:

  • 实现文字和图片在一个TextView中

activity_text_view.xml

<TextView
android:id="@+id/tv_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="树莓派"
android:drawableRight="@drawable/ic_launcher_background"
android:textSize="50sp"/>

效果显示图:

  • 实现文字删除线

创建一个普通TextView

<TextView
android:id="@+id/tv_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hzy"
android:textSize="50sp"/>

在java中进行添加删除线的效果

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);//去除锯齿
}
}

效果显示图

  • 实现下划线效果

如上,创建组件

<TextView
android:id="@+id/tv_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hzy"
android:textSize="24sp"/>

在java代码中做修改

public class TextViewActivity extends AppCompatActivity {
private TextView mtv5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text_view);
mtv5 = findViewById(R.id.tv_1);
mtv5.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//下划线
}
}

效果显示:

  • 实现文字走马灯效果

.xml文件

<TextView
android:id="@+id/tv_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dididiididahhdesfsdfdsfsdfsdfsdfsdfdsf"
android:textSize="34sp"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginTop="10dp"/>

显示效果图:

注意:遇事不决,清理缓存并重启

Android开发----开发工具的安装与TextView组件的更多相关文章

  1. vscode-wechat 小程序开发提示工具 vscode 安装

    vscode 安装 vscode-wechat vscode-wechat 小程序开发提示工具 ---- 有了小程序开发提示,开发很方便 https://segmentfault.com/a/1190 ...

  2. 前端开发Grunt工具的安装使用

    随着前端开发效果越来越丰富,前端的结构也越来越复杂,这个时候就需要一个工具来进行管理,可以帮你做语法校验,文件拼接,代码压缩,文件清理等等琐事,Grunt就是这么一个不错的工具. 安装并不复杂,只要先 ...

  3. SVN团队开发项目工具(安装以及使用)

    https://pan.baidu.com/s/1jJyo9ue  密码:ce9z

  4. Android APP安全评估工具 Drozer - 安装介绍

    一.Drozedr安装 注意事项:安装需要 JavaRuntime Environment (JRE) or Java Development Kit (JDK)环境, 没有安装的请先安装java环境 ...

  5. Xamarin Mono For Android 4.6.07004 完整离线安装破解版(C#开发Android、IOS工具)

      Xamarin是由Miguel de Icaza成立的一家新的独立公司,目的是给Mono一个继续奋斗的机会.Mono for Android (原名:MonoDroid)可以让开发人员使用 Mic ...

  6. 安装并配置 Android Studio 开发工具和 Genymotion 模拟器

    需求说明: 安装并配置 Android Studio 开发工具和 Genymotion 模拟器. 熟练使用 Genymotion 模拟器,掌握 Genymotion 模拟器的基本设置和程序安装. 实现 ...

  7. 简单的调用OpenCV库的Android NDK开发 工具Android Studio

    前言 本博客写于2017/08/11, 博主非专业搞安卓开发, 只是工作的需要倒腾了下Android NDK相关的开发, 博文中有什么不正确.不严格的地方欢迎指正哈    本文后续也许还会有删改, 就 ...

  8. Xamarin For Visual Studio 3.0.54.0 完整离线破解版(C# 开发Android、IOS工具 吾乐吧软件站分享)

    Xamarin For Visual Studio就是原本的Xamarin For Android 以及 Xamarin For iOS,最新版的已经把两个独立的插件合并为一个exe安装包了.为了区分 ...

  9. Android开发常用工具类

    来源于http://www.open-open.com/lib/view/open1416535785398.html 主要介绍总结的Android开发中常用的工具类,大部分同样适用于Java. 目前 ...

随机推荐

  1. java源码——文件读写和单词统计

    本文要解决的问题:"键盘输入一段英语语句,将这段话写入content.txt中,然后输出这段话,并且统计语句中英文单词的数目以及各个单词出现的次数." 分析问题知,核心是文件读写和 ...

  2. libecc:一个可移植的椭圆曲线密码学库

    libecc:一个可移植的椭圆曲线密码学库 这段时间要写毕设关于椭圆曲线的部分,就参考了一个椭圆曲线库的代码来编写.这个库中的代码的结构.风格和封装在我看来是十分完善的.用起来也比较方便,当作一个密码 ...

  3. OverFeat:Integrated Recognition, Localization and Detection using Convolutional Networks

    目录 概 主要内容 Sermanet P., Eigen D., Zhang X., Mathieu M., Fergus R., LeCun Y. OverFeat:integrated recog ...

  4. pytest之 fixture 实现机制

    一.相同测试数据存放优化 在讲 fixture 实现机制之前,插入一段内容 上次有个小伙伴问我说,类似下面的用例代码情况,每条测试用例的数据都一样的,我们可以怎么进行优化吗? 当然是可以的 其实我们可 ...

  5. v75.01 鸿蒙内核源码分析(远程登录篇) | 内核如何接待远方的客人 | 百篇博客分析OpenHarmony源码

    子曰:"不学礼,无以立 ; 不学诗,无以言 " <论语>:季氏篇 百篇博客分析.本篇为: (远程登录篇) | 内核如何接待远方的客人 设备驱动相关篇为: v67.03 ...

  6. VUE3 之 循环渲染

    1. 概述 老话说的好:单打独斗是不行的,要懂得合作. 言归正传,今天我们来聊聊 VUE3 的 循环渲染. 2. 循环渲染 2.1 循环渲染数组 <body> <div id=&qu ...

  7. Java Web程序设计笔记 • 【第10章 JSTL标签库】

    全部章节   >>>> 本章目录 10.1 JSTL 概述 10.1.1 JSTL 简介 10.1.1 JSTL 使用 10.1.2 实践练习 10.2 核心标签库 10.2. ...

  8. 对比显示每条线路的价格和该类型线路的平均价格,分别使用子查询和 exists 获取线路数量

    查看本章节 查看作业目录 需求说明: 对比显示每条线路的价格和该类型线路的平均价格 分别使用子查询和 exists 获取线路数量超过"出境游"线路数的线路类型信息,要求按照线路数升 ...

  9. Swoole 中使用 TCP 异步服务器、TCP 协程服务器、TCP 同步客户端、TCP 协程客户端

    TCP 异步风格服务器 异步风格服务器通过监听事件的方式来编写程序.当对应的事件发生时底层会主动回调指定的函数. 由于默认开启协程化,在回调函数内部会自动创建协程,遇到 IO 会产生协程调度,异步风格 ...

  10. [学习笔记] IT项目管理 - 挣值管理(EVM)

    挣值管理(EVM) 挣值管理(Earned Value Management, EVM)是成本管理里面较为重点的知识点,但是也可以用来综合考察项目范围.进度和成本绩效,经常需要做相关计算. 基本概念P ...