Android 开发笔记___textvieww__跑马灯效果
<?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__跑马灯效果的更多相关文章
- Android 使用TextView实现跑马灯效果
前言 我们在开发中经常会遇到一个小问题.比如下面一个小例子: 这个文字太长,单行中导致无法全部显示出来,这就是今天要实现的功能. 当然,百度中也有很多这种解决方案. 其中有一种,例如: <Tex ...
- Android学习总结——TextView跑马灯效果
Android系统中TextView实现跑马灯效果,必须具备以下几个条件: 1.android:ellipsize="marquee" 2.TextView必须单行显示,即内容必须 ...
- Android使用TextView实现跑马灯效果(自定义控件)
对于一个长的TetxView 折行显示是一个很好的办法,另一种方法就是跑马灯显示(单行滚动) 1.折行显示的长TextView <LinearLayout xmlns:android=" ...
- android用TextView实现跑马灯效果
今天搞啦很久,其实很简单,就加几个属性就可以啦! 图如下 : 有的说要重写TextView方法,有的说要设置固定长度,但是我没重写也没有设置固定长度也弄出来啦!跑在2.3.3的手机上面.就是不知道其他 ...
- Android 开发笔记___textview_聊天室效果
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Android 用ViewFlipper实现跑马灯效果的公告提示
1.代码部分private void initViewFlipper(final HomepageListModel.Notice notice) { for (int i = 0; i < n ...
- Android开发:文本控件详解——TextView(二)文字跑马灯效果实现
一.需要使用的属性: 1.android:ellipsize 作用:若文字过长,控制该控件如何显示. 对于同样的文字“Android开发:文本控件详解——TextView(二)文字跑马灯效果实现”,不 ...
- TextView的跑马灯效果(AS开发实战第二章学习笔记)
TextView的跑马灯效果跑马灯用到的属性与方法说明singleLine 指定文本是否单行显示ellipsize 指定文本超出范围后的省略方式focusable 指定是否获得焦点,跑马灯效果要求设置 ...
- android中实现跑马灯效果以及AutoCompleteTestView与MultiAutoCompleteTextView的学习
跑马灯效果 1.用过属性的方式实现跑马灯效果 属性: android:singleLine="true" 这个属性是设置TextView文本中文字 ...
随机推荐
- JAVA多线程---volatile关键字
加锁机制既可以确保可见性又可以保证原子性,而volatile变量只能确保可见性. 当把变量声明为volatile时候 编译器与运行时都会注意到这个变量是共享的,不会将该变量上的操作与其他内存操作一起重 ...
- 使用VMware Workstation Pro 12 虚拟机安装Mac OS系统教程 全程图解
导读:使用虚拟机安装Windows.Linux或者Ubuntu系统大家或许看了很多,但如何使用VMware Workstation Pro 12安装Mac OS,的确需要好好研究一番:否则无法下手,因 ...
- 【Java】关于Java8 parallelStream并发安全的思考
背景 Java8的stream接口极大地减少了for循环写法的复杂性,stream提供了map/reduce/collect等一系列聚合接口,还支持并发操作:parallelStream. 在爬虫开发 ...
- 【框架学习与探究之宿主服务--Topshelf】
前言 此文欢迎转载,原始链接地址:http://www.cnblogs.com/DjlNet/p/7603819.html 正文 原先也偶然见过这个关键词,当时只是有个大致了解貌似和WinServic ...
- 利用ASP.netCore自带DI(DependencyInjection)实现批量依赖注入
ASP.net Core自带DI(依赖注入),用法如下: services.AddScoped(typeof(IProductService), typeof(ProductService)); 如果 ...
- Python调用C# Com dll组件实战
之前公司有套C# AES加解密方案,但是方案加密用的是Rijndael类,而非AES的四种模式(ECB.CBC.CFB.OFB,这四种用的是RijndaelManaged类),Python下Crypt ...
- Java web JavaScript DOM 编程
JavaScript DOM 编程 (1).DOM概述及分类 (2).DOM结构模型:XML DOM 和 HTML DOM 关系? (3).结点,结点树,结点属性与方法? 1.DOM是什么? d ...
- tcpdump 使用实践
tcpdump常用配置指导 参考:http://www.cnblogs.com/ggjucheng/archive/2012/01/14/2322659.html 1. 指定端口抓包 -i 说明: ...
- Opencv如何捕获摄像头视频-OpenCV步步精深
捕获摄像头实时图像 这一点非常非常重要,因为这一点关乎了以后我们进行各种各样的识别(人脸识别,车牌识别等等有趣的识别).opencv提供了一个接口,可以轻松的让我们实现这个功能.我们先来看一段代码,根 ...
- jquery各种事件使用方法总结(from:天宇之游)
ps:本博客转自博主 天宇之游 ,地址:http://www.cnblogs.com/cwp-bg/ ,再次感谢天宇之游.jquery事件使用方法总结 一.鼠标事件1. click():鼠标单击事 ...