zoukankan      html  css  js  c++  java
  • Android app widget中实现跑马灯效果(非widget部件也实用)

    原文地址:http://blog.csdn.net/luoyebuguigen/article/details/37533631

    关键是需要在TextView中嵌入requestForcus标签才会有效果。

    <TextView   
            android:id="@+id/widget_item_name"  
            android:layout_height="wrap_content"  
            android:layout_width="wrap_content"  
            android:paddingLeft="10dip"  
            android:paddingRight="10dip"  
            android:text="Baby Room"  
            android:textColor="@android:color/white"  
            android:textSize="@dimen/testSize18"  
            android:singleLine="true"  
            android:ellipsize="marquee"  
            android:marqueeRepeatLimit="marquee_forever"  
            android:scrollHorizontally="true"  
            android:focusable="true"  
            android:focusableInTouchMode="true">  
            <requestFocus  
                android:focusable="true"  
                android:focusableInTouchMode="true"  
                android:duplicateParentState="true"/>  
        </TextView> 

    另外还有不使用ScrollView也可滚动的方法

    TextView textview = (TextView) findViewById(R.id.text);  
                /**             *
                 * 只有调用了该方法,TextView才能不依赖于ScrollView而实现滚动的效果。
                 * 要在XML中设置TextView的textcolor,否则,当TextView被触摸时,会灰掉。
                 */  
     
                textview.setMovementMethod(ScrollingMovementMethod.getInstance()); 

    xml如下:

    <TextView  
          android:layout_width="match_parent"  
          android:layout_height="wrap_content"  
          android:textSize="18sp"  
          android:scrollbars="vertical"  
           android:maxLines="12"  
          android:textColor="@color/white"  
          android:id="@+id/text"  
          android:text="hello world"  
         ></TextView> 

     备注:有些字符串为英文时,无法滚动,需要在字符串增加一个换行符

    // 单曲   有些歌曲名和艺术家名是英文,无法进行滚动,需要再后面加一个回车符
    ct_dec_playbar.setText(getString(R.string.play_title, title, artistname) + " ");
  • 相关阅读:
    路由器默认密码
    目前网络安全的攻击来源
    SQL注入——时间盲注
    UNIX网络编程第4章4.5listen函数4.6accept函数
    UNIX网络编程第3章套接字编程简介3.2套接字地址结构3.3值结果参数3.4字节排序函数
    Ubuntu软件系列---如何安装deb安装包
    Ubuntu软件系列---添加实时网速
    Ubuntu软件系列---网易云
    4.9 TF读入TFRecord
    4-8 使用tf.train.string_input_producer读取列表样本
  • 原文地址:https://www.cnblogs.com/baiyi168/p/5748202.html
Copyright © 2011-2022 走看看