zoukankan      html  css  js  c++  java
  • 关于跑马灯的体会

    1、 android:singleLine="true"虽然被不建议使用,但是跑马灯必须是它。如果改为android:maxLines="1",不能实现跑马灯效果。

    2、 android:marqueeRepeatLimit="marquee_forever" 是否使用,没关系。

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:text="跑马灯效果,点击暂停,再点击恢复" />
    
        <TextView
            android:id="@+id/tv_marquee"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:textColor="#000000"
            android:textSize="17sp"
            android:marqueeRepeatLimit="marquee_forever"
            android:text="快讯:红色预警,超强台风“莫兰蒂”即将登陆,请居民关紧门窗、备足粮草,做好防汛救灾准备!" />
    </LinearLayout>
    package com.example.administrator.myapplication50;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.TextView;
    
    public class MainActivity extends AppCompatActivity  implements View.OnClickListener {
    
        private TextView tv_marquee;
        private boolean bPause = false;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout3);
    
            tv_marquee = (TextView) findViewById(R.id.tv_marquee);
            tv_marquee.setOnClickListener(this);
    
        }
    
        @Override
        public void onClick(View v) {
            if (v.getId() == R.id.tv_marquee) {
                bPause = !bPause;
                if (bPause) {
                    tv_marquee.setFocusable(false);
                    tv_marquee.setFocusableInTouchMode(false);
                } else {
                    tv_marquee.setFocusable(true);
                    tv_marquee.setFocusableInTouchMode(true);
                }
            }
        }
    }
  • 相关阅读:
    November 07th, 2017 Week 45th Tuesday
    November 06th, 2017 Week 45th Monday
    November 05th, 2017 Week 45th Sunday
    November 04th, 2017 Week 44th Saturday
    November 03rd, 2017 Week 44th Friday
    Asp.net core 学习笔记 ( Area and Feature folder structure 文件结构 )
    图片方向 image orientation Exif
    Asp.net core 学习笔记 ( Router 路由 )
    Asp.net core 学习笔记 ( Configuration 配置 )
    qrcode render 二维码扫描读取
  • 原文地址:https://www.cnblogs.com/qqhfeng/p/7368322.html
Copyright © 2011-2022 走看看