亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android 上下滾動TextSwitcher實(shí)例詳解

 更新時(shí)間:2017年06月06日 17:25:29   投稿:lqh  
這篇文章主要介紹了Android 上下滾動TextSwitcher實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下

Android 上下滾動TextSwitcher實(shí)例詳解

1.在activity中需要代碼聲明

textSwitcher = (TextSwitcher)findViewById(R.id.text_switcher); 
    textSwitcher.setFactory(new ViewFactory() { 
       
      @Override 
      public View makeView() { 
        TextView tv = new  TextView(MainActivity.this); 
        tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16.0F); 
        tv.setTextColor(Color.RED); 
        return tv; 
      } 
    }); 
     
    textSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_in)); 
    textSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_out)); 

2.兩個(gè)anim動畫xml

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
   android:fillAfter="true"  
  android:shareInterpolator="false"  android:zAdjustment="top"> 
  <translate  
    android:duration="3000"  
    android:fromYDelta="100%p"  
    android:toYDelta="0" /> 
</set> 
<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
  android:fillAfter="true"  
  android:shareInterpolator="false"  android:zAdjustment="top"> 
   
   <translate  
    android:duration="3000"  
    android:fromYDelta="0"  
    android:toYDelta="-100%p" />  
</set> 
<style name="pop_anim"> 
    <item name="android:windowEnterAnimation">@anim/anim_in</item> 
  <item name="android:windowExitAnimation">@anim/anim_out</item> 
  </style> 

3.用線程或者定時(shí)器實(shí)現(xiàn)循環(huán)翻動。

Thread t = new Thread(new Runnable() { 
     
    @Override 
    public void run() { 
      while (!flag) { 
        Message msg = new Message(); 
        msg.what = 1; 
        msg.obj = getItem[i]; 
        handler.sendMessage(msg); 
        if (i== 2) { 
          i = 0; 
        } 
        try { 
          t.sleep(3000); 
          i++; 
           
        } catch (InterruptedException e) { 
          // TODO Auto-generated catch block 
          e.printStackTrace(); 
        } 
      } 
       
    } 

4.hanlder更新ui

private Handler handler = new Handler(){ 
    public void handleMessage(android.os.Message msg) { 
       
      textSwitcher.setText((String)msg.obj); 
       
      super.handleMessage(msg); 
    }; 
  }; 

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

  • Android使用Intent實(shí)現(xiàn)頁面跳轉(zhuǎn)

    Android使用Intent實(shí)現(xiàn)頁面跳轉(zhuǎn)

    這篇文章主要為大家詳細(xì)介紹了Android使用Intent實(shí)現(xiàn)頁面跳轉(zhuǎn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • Android系統(tǒng)服務(wù)是如何獲取的

    Android系統(tǒng)服務(wù)是如何獲取的

    這篇文章主要介紹了Android系統(tǒng)服務(wù)是如何獲取的,幫助大家更好的理解和學(xué)習(xí)使用Android開發(fā),感興趣的朋友可以了解下
    2021-03-03
  • android上實(shí)現(xiàn)0.5px線條的原理分析

    android上實(shí)現(xiàn)0.5px線條的原理分析

    這篇文章主要介紹了android上實(shí)現(xiàn)0.5px線條的原理分析,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-01-01
  • Android實(shí)現(xiàn)注冊頁面

    Android實(shí)現(xiàn)注冊頁面

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)注冊頁面之監(jiān)聽器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Android使用Intent.ACTION_SEND分享圖片和文字內(nèi)容的示例代碼

    Android使用Intent.ACTION_SEND分享圖片和文字內(nèi)容的示例代碼

    這篇文章主要介紹了Android使用Intent.ACTION_SEND分享圖片和文字內(nèi)容的示例代碼的實(shí)例代碼,具有很好的參考價(jià)值,希望對大家有所幫助,一起跟隨小編過來看看吧
    2018-05-05
  • Android實(shí)現(xiàn)動態(tài)向Gallery中添加圖片及倒影與3D效果示例

    Android實(shí)現(xiàn)動態(tài)向Gallery中添加圖片及倒影與3D效果示例

    這篇文章主要介紹了Android實(shí)現(xiàn)動態(tài)向Gallery中添加圖片及倒影與3D效果的方法,涉及Android針對圖片的加載、顯示、翻轉(zhuǎn)、倒影等相關(guān)特效功能實(shí)現(xiàn)技巧
    2016-08-08
  • 分享五種Android常用布局方式

    分享五種Android常用布局方式

    Android布局是應(yīng)用界面開發(fā)的重要一環(huán),在Android中,共有五種布局方式,分別是:FrameLayout(框架布 局),LinearLayout (線性布局),AbsoluteLayout(絕對布局),RelativeLayout(相對布局),TableLayout(表格布局),小編通過本文逐一給大家詳解
    2015-11-11
  • Android編程之軟件的安裝和卸載方法

    Android編程之軟件的安裝和卸載方法

    這篇文章主要介紹了Android編程之軟件的安裝和卸載方法,涉及Android編程實(shí)現(xiàn)軟件的安裝、權(quán)限修改及卸載的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-12-12
  • Android動態(tài)顯示具體到秒的相聚時(shí)間

    Android動態(tài)顯示具體到秒的相聚時(shí)間

    這篇文章主要為大家詳細(xì)介紹了Android動態(tài)顯示具體到秒的相聚時(shí)間,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-05-05
  • android實(shí)現(xiàn)單選按鈕功能

    android實(shí)現(xiàn)單選按鈕功能

    這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)單選按鈕功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05

最新評論