zoukankan      html  css  js  c++  java
  • TextView文字横向自己主动滚动

              效果截图:

     

                              

    布局文件:

    <?xml version="1.0" encoding="utf-8"?

    >
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:orientation="vertical"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:background="#ffffff"
                  android:gravity="center"
            >

        <TextView android:id="@+id/text1"
                  android:layout_width="80dp"
                  android:layout_height="40dp"
                  android:ellipsize="marquee"
                  android:marqueeRepeatLimit="marquee_forever"
                  android:focusable="true"
                  android:scrollHorizontally="true"
                  android:focusableInTouchMode="true"
                  android:layout_centerInParent="true"
                  android:textColor="#0551A5"
                  android:layout_marginLeft="20dp"
                  android:layout_marginRight="20dp"
                  android:singleLine="true"/>
        <!--android:focusable="true"是否获取焦点-->
        <!--focusableInTouchMode:通过触摸获取焦点-->
        <!--android:ellipsize="marquee"设置为跑马灯-->
        <!--android:marqueeRepeatLimit="marquee_forever"滚动次数里面能够直接写数字-->
        <!--marquee_forever表示永远滚动-->
        <!--android:scrollHorizontally="true"水平滚动-->
        <!--android:singleLine="true"单行输入-->
    </LinearLayout>

    Java代码:

    package com.example.MargueeTextView;

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;

    public class MyActivity extends Activity {
        private TextView text1;
        /**
         * Called when the activity is first created.
         */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            text1=(TextView)findViewById(R.id.text1);
            text1.setText("春光无限好,仅仅是近黄昏………………");
        }
    }

     源代码下载地址

     

  • 相关阅读:
    数据库日志文件很大,如何变小!
    导出到CSV文件乱码的问题
    JQuery 常用方法一览
    马云在阿里巴巴十周年晚会上的激情演讲
    jqueryeasyui(替代 extjs) 介绍
    写一个ajax程序就是如此简单
    ASP.NET 3.5之屠龙刀
    因并发而生,因云计算而热(专家聊天实录)
    专家访谈:为什么我们需要Erlang
    《写给大家看的设计书》封面评选结果揭晓
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/8831039.html
Copyright © 2011-2022 走看看