<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="演示效果"
android:textColor="@color/text_color"
android:textSize="25sp"
android:layout_gravity="center"/> <LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="250dp"> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="跑马灯效果,点击暂停,再点击恢复"/> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tv_marquee"
android:layout_marginTop="20dp"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:textColor="#000000"
android:textSize="17sp"
android:text="快讯:红色预警,超高温度即将到来,请吐鲁番居民关紧门窗、备足粮草,打开空调,做好防汛救灾准备!"/> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="聊天室效果"
android:layout_marginTop="10dp"
android:id="@+id/btn_liaotianshi"/> </LinearLayout> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="主要内容"
android:textColor="@color/text_color"
android:textSize="25sp"
android:layout_gravity="center"/> <ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"> <TextView
android:textColor="@color/text_color"
android:text="1.跑马灯效果\n首先设置为单行(singleline),再设置超出范围后的省略方式(有三种:1、start 2、middle 3、end ,当设置为marquee时就是跑马灯效果)。还需要获取焦点,设置focusable=true,focusableInTouchMode=true\n\n2、聊天室效果\nscrollbars是vertical,在代码中设置set movementmethod"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /> </ScrollView> </LinearLayout>

java

 package com.example.alimjan.hello_world;

 import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button; /**
* Created by alimjan on 6/30/2017.
*/ public class class__2_3_1 extends Activity {
private Button lts;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.code_2_3_1); lts = (Button) findViewById(R.id.btn_liaotianshi); lts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(class__2_3_1.this, class__2_3_1_2.class);
class__2_3_1.this.startActivity(intent);
}
}); } public static void startHome(Context mContext) {
Intent intent = new Intent(mContext, class__2_3_1.class);
mContext.startActivity(intent);
}
}

Android 开发笔记___textvieww__跑马灯效果的更多相关文章

  1. Android 使用TextView实现跑马灯效果

    前言 我们在开发中经常会遇到一个小问题.比如下面一个小例子: 这个文字太长,单行中导致无法全部显示出来,这就是今天要实现的功能. 当然,百度中也有很多这种解决方案. 其中有一种,例如: <Tex ...

  2. Android学习总结——TextView跑马灯效果

    Android系统中TextView实现跑马灯效果,必须具备以下几个条件: 1.android:ellipsize="marquee" 2.TextView必须单行显示,即内容必须 ...

  3. Android使用TextView实现跑马灯效果(自定义控件)

    对于一个长的TetxView 折行显示是一个很好的办法,另一种方法就是跑马灯显示(单行滚动) 1.折行显示的长TextView <LinearLayout xmlns:android=" ...

  4. android用TextView实现跑马灯效果

    今天搞啦很久,其实很简单,就加几个属性就可以啦! 图如下 : 有的说要重写TextView方法,有的说要设置固定长度,但是我没重写也没有设置固定长度也弄出来啦!跑在2.3.3的手机上面.就是不知道其他 ...

  5. Android 开发笔记___textview_聊天室效果

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  6. Android 用ViewFlipper实现跑马灯效果的公告提示

    1.代码部分private void initViewFlipper(final HomepageListModel.Notice notice) { for (int i = 0; i < n ...

  7. Android开发:文本控件详解——TextView(二)文字跑马灯效果实现

    一.需要使用的属性: 1.android:ellipsize 作用:若文字过长,控制该控件如何显示. 对于同样的文字“Android开发:文本控件详解——TextView(二)文字跑马灯效果实现”,不 ...

  8. TextView的跑马灯效果(AS开发实战第二章学习笔记)

    TextView的跑马灯效果跑马灯用到的属性与方法说明singleLine 指定文本是否单行显示ellipsize 指定文本超出范围后的省略方式focusable 指定是否获得焦点,跑马灯效果要求设置 ...

  9. android中实现跑马灯效果以及AutoCompleteTestView与MultiAutoCompleteTextView的学习

    跑马灯效果 1.用过属性的方式实现跑马灯效果 属性:                  android:singleLine="true" 这个属性是设置TextView文本中文字 ...

随机推荐

  1. E - 钱币兑换问题

          在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法.请你编程序计算出共有多少种兑法. Input每行只有一个正整数N,N小于32768. Output对应每个输入,输出兑换方 ...

  2. Java钉钉开发_02_免登授权(身份验证)(附源码)

    源码已上传GitHub: https://github.com/shirayner/DingTalk_Demo 一.本节要点 1.免登授权的流程 (1)签名校验 (2)获取code,并传到后台 (3) ...

  3. Linux入门之常用命令(4)vi编辑器

    vi分为三种模式 一般模式:删除字符.删除整行.复制粘贴等操作 编辑模式:i o a r进入 输入字符  Esc退出 命令行模式::或/ 将光标移动到最末行 搜寻数据 读取或替换 退出vi 显示行号 ...

  4. 使用Xshell+Xmanager远程监控jvisualvm

    使用jvisualvm的remote方式监控服务器端jvisualvm时,不是很方便,因此通过local方式,应该是正路. 一.服务器端(Linux,最小安装模式,没有图形界面) 1.安装xauth ...

  5. Android 导入引用第三方项目

    环境:Android Studio 1.4 1 以源工程形式导入 第一步,导入项目 File--New--Import Module--->设置导入后的项目名称 第二部,在自己工程中添加Depe ...

  6. ocs的沟通平台

    Microsoft Office Communications Server 2007 R2 简称:OCS准时准确地联系人员以及管理信息过载根据人员的状态与其联系,然后单击最佳方式与其通信:通过电子邮 ...

  7. Java面向对象 网络编程 下

    Java面向对象 网络编程  下 知识概要:                   (1)Tcp 练习 (2)客户端向服务端上传一个图片. (3) 请求登陆 (4)url 需求:上传图片. 客户端:   ...

  8. Java面向对象 线程技术 -- 下篇

     Java面向对象 线程技术 -- 下篇 知识概要:              (1)线程间的通信           生产者 - 消费者 (2)生产者消费者案例优化 (3)守护线程 (4)停止线 ...

  9. MVC调用部分视图PartialView

    using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Demo2 ...

  10. UWP 手绘视频创作工具技术分享系列 - 位图的绘制

    前面我们针对 SVG 的解析和绘制做了介绍,SVG 是图片的一种形式,而另一种很重要的图片是:位图,包括 png.jpeg.bmp 等格式.位图的基本规则是,组成的基本元素是像素点,由宽度 * 高度个 ...