Android TextSwitcher實(shí)現(xiàn)文字上下翻牌效果(銅板街)
tvNotice = (TextSwitcher)rootView.findViewById(R.id.tv_notice);
tvNotice.setFactory(new ViewSwitcher.ViewFactory() {
//這里 用來(lái)創(chuàng)建內(nèi)部的視圖,這里創(chuàng)建TextView,用來(lái)顯示文字
public View makeView() {
TextView tv =new TextView(getContext());
//設(shè)置文字大小
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX,getResources().getDimension(R.dimen.group_notice_font_size));
//設(shè)置文字 顏色
tv.setTextColor(getResources().getColor(R.color.font_333333));
return tv;
}
});
然后自己可用timer或者Thread去控制輪播,輪播中控制tvNotice的代碼如下
// 設(shè)置切入動(dòng)畫 tvNotice.setInAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_bottom)); // 設(shè)置切出動(dòng)畫 tvNotice.setOutAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.slide_out_up)); //items是一個(gè)字符串列表,index就是動(dòng)態(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實(shí)現(xiàn)文字上下翻牌效果(銅板街),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的,在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Android自定義控件實(shí)現(xiàn)邊緣凹凸的卡劵效果
這篇文章主要介紹了Android自定義控件實(shí)現(xiàn)邊緣凹凸的卡劵效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07
Android ListView 子控件onClick正確獲取position的方法
這篇文章主要介紹了Android ListView 子控件onClick正確獲取position的方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的的朋友參考下吧2017-01-01
Android如何實(shí)現(xiàn)動(dòng)態(tài)滾動(dòng)波形圖(心電圖)功能
這篇文章主要介紹了Android如何實(shí)現(xiàn)動(dòng)態(tài)滾動(dòng)波形圖(心電圖)功能,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2021-03-03
Android編程使用ListView實(shí)現(xiàn)數(shù)據(jù)列表顯示的方法
這篇文章主要介紹了Android編程使用ListView實(shí)現(xiàn)數(shù)據(jù)列表顯示的方法,實(shí)例分析了Android中ListView控件的使用技巧,需要的朋友可以參考下2016-01-01
Android Studio 3.0上分析內(nèi)存泄漏的原因
本篇文章主要介紹了Android Studio 3.0上分析內(nèi)存泄漏的原因,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-11-11
Android?IntentFilter的匹配規(guī)則示例詳解
這篇文章主要為大家介紹了Android?IntentFilter的匹配規(guī)則示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12
Android PickerView底部選擇框?qū)崿F(xiàn)流程詳解
本次主要介紹Android中底部彈出框的使用,使用兩個(gè)案例來(lái)說(shuō)明,首先是時(shí)間選擇器,然后是自定義底部彈出框的選擇器,以下來(lái)一一說(shuō)明他們的使用方法2022-09-09
Android中Glide實(shí)現(xiàn)超簡(jiǎn)單的圖片下載功能
本篇文章主要介紹了Android中Glide實(shí)現(xiàn)超簡(jiǎn)單的圖片下載功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-03-03
Android編程實(shí)現(xiàn)通知欄進(jìn)度條效果的方法示例
這篇文章主要介紹了Android編程實(shí)現(xiàn)通知欄進(jìn)度條效果的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了Android通知欄進(jìn)度條效果的功能、布局相關(guān)實(shí)現(xiàn)方法與操作注意事項(xiàng),需要的朋友可以參考下2018-02-02

