Android TextSwitcher實現(xiàn)文字上下翻牌效果(銅板街)
更新時間:2017年05月21日 17:40:29 作者:ganchuanpu
這篇文章主要介紹了Android TextSwitcher實現(xiàn)文字上下翻牌效果(銅板街),需要的朋友可以參考下
tvNotice = (TextSwitcher)rootView.findViewById(R.id.tv_notice); tvNotice.setFactory(new ViewSwitcher.ViewFactory() { //這里 用來創(chuàng)建內(nèi)部的視圖,這里創(chuàng)建TextView,用來顯示文字 public View makeView() { TextView tv =new TextView(getContext()); //設置文字大小 tv.setTextSize(TypedValue.COMPLEX_UNIT_PX,getResources().getDimension(R.dimen.group_notice_font_size)); //設置文字 顏色 tv.setTextColor(getResources().getColor(R.color.font_333333)); return tv; } });
然后自己可用timer或者Thread去控制輪播,輪播中控制tvNotice的代碼如下
// 設置切入動畫 tvNotice.setInAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_bottom)); // 設置切出動畫 tvNotice.setOutAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.slide_out_up)); //items是一個字符串列表,index就是動態(tài)的要顯示的items中的索引 tvNotice.setText(itmes.get(index).getTitle());
slide_in_bottom.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="1000" android:fromYDelta="100%p" android:toYDelta="0" /> </set>
slide_out_up.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="1000" android:fromYDelta="0" android:toYDelta="-100%p" /> </set>
以上所述是小編給大家介紹的Android TextSwitcher實現(xiàn)文字上下翻牌效果(銅板街),希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的,在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章:
相關文章
Android使用kotlin實現(xiàn)多行文本上下滾動播放
這篇文章主要為大家詳細介紹了Android使用kotlin實現(xiàn)多行文本的上下滾動播放,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-01-01HttpURLConnection和okHttp兩種獲取網(wǎng)絡數(shù)據(jù)的實現(xiàn)方法
下面小編就為大家分享一篇HttpURLConnection和okHttp兩種獲取網(wǎng)絡數(shù)據(jù)的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01Android Textview實現(xiàn)顏色漸變滾動效果
這篇文章主要為大家詳細介紹了Android Textview實現(xiàn)顏色漸變滾動效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-10-10android使用Ultra-PullToRefresh實現(xiàn)下拉刷新自定義代碼
本篇文章主要介紹了android使用Ultra-PullToRefresh實現(xiàn)下拉刷新新自定義,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-02-02