最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android 中TextView中跑馬燈效果的實現(xiàn)方法

 更新時間:2017年02月21日 13:49:24   作者:楊天福  
這篇文章主要介紹了Android 中TextView中跑馬燈效果的實現(xiàn)方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下

 條件:

1、android:ellipsize=”marquee”

2、TextView必須單行顯示,即內(nèi)容必須超出TextView大小

3、TextView要獲得焦點才能滾動

mTVText.setText(“超過文本長度的數(shù)據(jù)");

mTVText.setSingleLine(true);設(shè)置單行顯示

mTVText.setEllipsize(TruncateAt.MARQUEE);設(shè)置跑馬燈顯示效果

TextView.setHorizontallyScrolling(true); //讓文字可以水平滑動

TextView還可以設(shè)置跑馬燈效果的滾動次數(shù)

android:marqueerepeatlimit="1"。1代表1次,-1代表無限循環(huán)。

Java代碼設(shè)置:

mTVText.setMarqueeRepeatLimit(-1);

.xml文件:

<TextView
    android:id="@+id/tv_marquee"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/tv_marquee_text"
    android:textSize="25sp"
    android:focusable="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:focusableInTouchMode="true"
    android:textColor="@color/colorPrimary" />

.Java文件

public class LampRunActivity extends AppCompatActivity {
  private TextView tv_marguee;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lamp_run);
    intiTextView();
  }
  public void intiTextView(){
    tv_marguee= (TextView) findViewById(R.id.tv_marquee);
    tv_marguee.setSingleLine(true);//設(shè)置單行顯示
    tv_marguee.setHorizontallyScrolling(true);//設(shè)置水平滾動效果
//    tv_marguee.setMarqueeRepeatLimit(-1);//設(shè)置滾動次數(shù),-1為無限滾動,1為滾動1次

相關(guān)文章

最新評論

隆回县| 甘孜县| 徐闻县| 集安市| 视频| 武定县| 道孚县| 迁西县| 寿阳县| 沭阳县| 齐齐哈尔市| 龙井市| 含山县| 交口县| 遵义县| 滁州市| 闵行区| 汤阴县| 通化市| 禄劝| 南汇区| 大余县| 成武县| 射洪县| 古丈县| 东乡县| 贺兰县| 靖边县| 丹江口市| 惠东县| 辉南县| 夏河县| 临夏市| 东安县| 榆树市| 贡嘎县| 明星| 潮安县| 镶黄旗| 洛宁县| 宾川县|