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());
//設(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è)置切入動畫 tvNotice.setInAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_bottom)); // 設(shè)置切出動畫 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)文字上下翻牌效果(銅板街),希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復(fù)大家的,在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
Android ListView 子控件onClick正確獲取position的方法
這篇文章主要介紹了Android ListView 子控件onClick正確獲取position的方法,非常不錯,具有參考借鑒價值,需要的的朋友參考下吧2017-01-01
Android如何實現(xiàn)動態(tài)滾動波形圖(心電圖)功能
這篇文章主要介紹了Android如何實現(xiàn)動態(tài)滾動波形圖(心電圖)功能,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2021-03-03
Android編程使用ListView實現(xiàn)數(shù)據(jù)列表顯示的方法
這篇文章主要介紹了Android編程使用ListView實現(xiàn)數(shù)據(jù)列表顯示的方法,實例分析了Android中ListView控件的使用技巧,需要的朋友可以參考下2016-01-01
Android Studio 3.0上分析內(nèi)存泄漏的原因
本篇文章主要介紹了Android Studio 3.0上分析內(nèi)存泄漏的原因,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-11-11
Android?IntentFilter的匹配規(guī)則示例詳解
這篇文章主要為大家介紹了Android?IntentFilter的匹配規(guī)則示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-12-12
Android PickerView底部選擇框?qū)崿F(xiàn)流程詳解
本次主要介紹Android中底部彈出框的使用,使用兩個案例來說明,首先是時間選擇器,然后是自定義底部彈出框的選擇器,以下來一一說明他們的使用方法2022-09-09
Android中Glide實現(xiàn)超簡單的圖片下載功能
本篇文章主要介紹了Android中Glide實現(xiàn)超簡單的圖片下載功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-03-03
Android編程實現(xiàn)通知欄進度條效果的方法示例
這篇文章主要介紹了Android編程實現(xiàn)通知欄進度條效果的方法,結(jié)合實例形式較為詳細的分析了Android通知欄進度條效果的功能、布局相關(guān)實現(xiàn)方法與操作注意事項,需要的朋友可以參考下2018-02-02

