标签:.text touch support cte onclick pack activity ica imp
activity_marquee.xml
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="下面演示跑马灯"
        android:layout_marginTop="50dp"
        android:textSize="36sp"
        />
    <TextView
        android:id="@+id/tvMarquee"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:ellipsize="marquee"
        android:singleLine="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:textSize="24sp"
        android:text="快讯:预警信息,台风来袭,请注意防汛信息。台风来袭,请注意防汛信息台风来袭,请注意防汛信息台风来袭,请注意防汛信息台风来袭,请注意防汛信息" />
</LinearLayout>
-------------------------------------------------
MarqueeActivity.java
package com.example.dfby.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MarqueeActivity extends AppCompatActivity {
    private TextView tvMarquee;
    private boolean isPause=false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_marquee);
        tvMarquee=findViewById(R.id.tvMarquee);
        tvMarquee.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(isPause){
                    tvMarquee.setFocusable(true);
                    tvMarquee.setFocusableInTouchMode(true);
                }else{
                    tvMarquee.setFocusable(false);
                    tvMarquee.setFocusableInTouchMode(false);
                }
                isPause=!isPause;
            }
        });
    }
}
标签:.text touch support cte onclick pack activity ica imp
原文地址:https://www.cnblogs.com/bj-tony/p/10243514.html