簡單實現跑馬燈

2021-08-30 15:15:18 字數 1610 閱讀 2795

1.//可以自己實現自定義view

public class marqueetestview extends textview implements runnable

/*** 畫筆工具

*/@override

protected void ondraw(canvas canvas)

}@override

public void setvisibility(int visibility)

@override

public void run()

hascircled += 1;

}if (!flag)

}/**

* 獲取文字顯示長度

*/private void gettextwidth()

textwidth = (int) paint.measuretext(str);

}/**

* 設定滾動次數,達到次數後設定不可見

** @param circletimes

*/public void setcircletimes(int circletimes)

public void setspeed(int speed)

public void startscrollshow()

private void stopscroll()

@override

public boolean isfocused()

}//布局

第三方依賴

//匯入依賴

implementation 'com.gongwen:marqueelibrary:1.1.3'

//在activity或fragment中寫

final listdatas = arrays.aslist("恭喜強哥購買了一件衣服");

******marqueeviewmarqueeview = (******marqueeview) get(r.id.******marqueeview);

******mfmarqueefactory = new ******mf(context);

marqueefactory.setdata(datas);

marqueeview.setmarqueefactory(marqueefactory);

marqueeview.startflipping();

//布局檔案

android:id="@+id/******marqueeview"

android:layout_width="match_parent"

android:layout_height="40dp"

android:layout_below="@+id/grid_home"

android:flipinterval="2500"

android:inanimation="@anim/in_top"

android:outanimation="@anim/out_bottom"

@override

public void onstart()

@override

public void onstop()

WPF 實現簡單的跑馬燈

本文用wpf的動畫實現乙個簡單的跑馬燈 xmal 下面是乙個最簡單的例子,就讓label動起來 public mainwindow 然後進入正題,利用定時器實現乙個簡單的迴圈滾動3個label的跑馬燈 關鍵點在於第三個lab滾動的時候怎麼銜接第乙個lab,其實很簡單,就是多new了乙個和第乙個lab...

jQuery實現跑馬燈

前段時間做專案乙個需求,輪播方式實現不了,自己寫了乙個跑馬燈實現效果。html class container class scroll div class scroll begin href 文字1a li href 文字2a li href 文字3a li href 文字4a li href 文...

跑馬燈效果

cgrect frame labelshow.frame frame.origin.x 180 labelshow.frame frame uiview beginanimations testanimation context null uiview setanimationduration 8....