1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical" android:layout_width="match_parent"
  4. android:layout_height="match_parent">
  5.  
  6. <TextView
  7. android:layout_width="wrap_content"
  8. android:layout_height="wrap_content"
  9. android:text="演示效果"
  10. android:textColor="@color/text_color"
  11. android:textSize="25sp"
  12. android:layout_gravity="center"/>
  13.  
  14. <LinearLayout
  15. android:layout_width="match_parent"
  16. android:orientation="vertical"
  17. android:layout_height="250dp">
  18.  
  19. <TextView
  20. android:layout_width="match_parent"
  21. android:layout_height="wrap_content"
  22. android:layout_marginTop="20dp"
  23. android:gravity="center"
  24. android:text="跑马灯效果,点击暂停,再点击恢复"/>
  25.  
  26. <TextView
  27. android:layout_width="match_parent"
  28. android:layout_height="wrap_content"
  29. android:id="@+id/tv_marquee"
  30. android:layout_marginTop="20dp"
  31. android:singleLine="true"
  32. android:ellipsize="marquee"
  33. android:focusable="true"
  34. android:focusableInTouchMode="true"
  35. android:textColor="#000000"
  36. android:textSize="17sp"
  37. android:text="快讯:红色预警,超高温度即将到来,请吐鲁番居民关紧门窗、备足粮草,打开空调,做好防汛救灾准备!"/>
  38.  
  39. <Button
  40. android:layout_width="wrap_content"
  41. android:layout_height="wrap_content"
  42. android:text="聊天室效果"
  43. android:layout_marginTop="10dp"
  44. android:id="@+id/btn_liaotianshi"/>
  45.  
  46. </LinearLayout>
  47.  
  48. <TextView
  49. android:layout_width="wrap_content"
  50. android:layout_height="wrap_content"
  51. android:text="主要内容"
  52. android:textColor="@color/text_color"
  53. android:textSize="25sp"
  54. android:layout_gravity="center"/>
  55.  
  56. <ScrollView
  57. android:layout_width="match_parent"
  58. android:layout_height="wrap_content">
  59.  
  60. <TextView
  61. android:textColor="@color/text_color"
  62. android:text="1.跑马灯效果\n首先设置为单行(singleline),再设置超出范围后的省略方式(有三种:1、start 2、middle 3、end ,当设置为marquee时就是跑马灯效果)。还需要获取焦点,设置focusable=true,focusableInTouchMode=true\n\n2、聊天室效果\nscrollbars是vertical,在代码中设置set movementmethod"
  63. android:layout_width="wrap_content"
  64. android:layout_height="wrap_content" />
  65.  
  66. </ScrollView>
  67.  
  68. </LinearLayout>

java

  1. package com.example.alimjan.hello_world;
  2.  
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.os.Bundle;
  7. import android.support.annotation.Nullable;
  8. import android.view.View;
  9. import android.widget.Button;
  10.  
  11. /**
  12. * Created by alimjan on 6/30/2017.
  13. */
  14.  
  15. public class class__2_3_1 extends Activity {
  16. private Button lts;
  17. @Override
  18. protected void onCreate(@Nullable Bundle savedInstanceState) {
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.code_2_3_1);
  21.  
  22. lts = (Button) findViewById(R.id.btn_liaotianshi);
  23.  
  24. lts.setOnClickListener(new View.OnClickListener() {
  25. @Override
  26. public void onClick(View v) {
  27. Intent intent = new Intent(class__2_3_1.this, class__2_3_1_2.class);
  28. class__2_3_1.this.startActivity(intent);
  29. }
  30. });
  31.  
  32. }
  33.  
  34. public static void startHome(Context mContext) {
  35. Intent intent = new Intent(mContext, class__2_3_1.class);
  36. mContext.startActivity(intent);
  37. }
  38. }

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. springmvc 格式化返回日期格式

    <mvc:annotation-driven conversion-service="conversionService"> <mvc:message-conve ...

  2. Java虚拟机-运行时数据区域

    Java虚拟机管理的内存包括如图所示的运行时数据区域: 下面分别进行介绍: 1)程序计数器(Program Counter Register) 占用的内存空间比较小,主要作用就是标识当前线程执行的字节 ...

  3. UI自动化测试(二)浏览器操作及对元素的定位方法(xpath定位和css定位详解)

    Selenium下的Webdriver工具支持FireFox(geckodriver). IE(InternetExplorerDriver).Chrome(ChromeDriver). Opera( ...

  4. CSS中新属性calc()

    CSS3的calc()使用 原文: http://www.w3cplus.com/css3/how-to-use-css3-calc-function.html © w3cplus.com calc( ...

  5. win2003服务器定时自动重启命令

    1. win2003可以这样自动重启: 新建一个命令行文件比如reboot.bat 内容如下:shutdown -r -t 30 在计划任务中新建一个任务,程序选择上面这个reboot.cmd文件,时 ...

  6. IIS ApplicationPoolIdentity(配置IIS讀寫網站文件)

    原创地址:http://www.cnblogs.com/jfzhu/p/4067297.html 转载请注明出处 从IIS 7.5开始,Application Pool Identity的Built- ...

  7. win10 uwp 通知Toast

    win10通知使用Toast 可以使用win10 模板添加通知 var t = Windows.UI.Notifications.ToastTemplateType.ToastText02; 使用Ge ...

  8. 张高兴的 Windows 10 IoT 开发笔记:红外温度传感器 MLX90614

    GitHub : https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/MLX90614

  9. OpenWRT (RT5350) 使能两个串口

    OpenWRT(RT5350) 默认使能一个串口(uartlite) ,当做console口了,另外一个串口(uartf)与gpio复用. 在查找资料的过程中,发现在新的内核中使用到了设备树(devi ...

  10. (转)十分钟入门pandas

    本文是对pandas官方网站上<10 Minutes to pandas>的一个简单的翻译,原文在这里.这篇文章是对pandas的一个简单的介绍,详细的介绍请参考:Cookbook . 习 ...