当前位置:网站首页>textSwitch文本切换器的功能和用法
textSwitch文本切换器的功能和用法
2022-07-07 15:40:00 【XLMN】
textSwitch文本切换器的功能和用法
testswitch继承了viewswitch,因此据有和viewswitcher相同的特征,可以在切换view组件时使用动画效果,
testswitcher和imageview相识需要设置一个viewfactory,不同的在于,testswitcher需要viewfactory的makeview返回一个textview组件
public class MainActivity extends Activity {
TextSwitcher ts;
String[] str=new String[]{
“mia”,“love mia”,“miss mia”,“010802”
};
int curstr;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.textswitcher);
ts = (TextSwitcher) findViewById(R.id.textswitcher);
ts.setFactory(new ViewFactory() {
@Override
public View makeView() {
// TODO Auto-generated method stub
TextView tv=new TextView(MainActivity.this);
tv.setTextSize(40);
tv.setTextColor(Color.MAGENTA);
return tv;
}
});
next(null);
}
//定义处理函数,控制显示下一个字符串
public void next(View source) {
ts.setText(str[curstr++%str.length]);
}
}
<?xml version="1.0" encoding="utf-8"?><!-- 定义一个testswitcher,并指定文本切换时的动画效果 -->
<TextSwitcher
android:id="@+id/textswitcher"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inAnimation="@android:anim/slide_in_left"
android:onClick="next"
android:outAnimation="@android:anim/slide_out_right" >
</TextSwitcher>
边栏推荐
- Devops' operational and commercial benefits Guide
- How to mount the original data disk without damage after the reinstallation of proxmox ve?
- Sator推出Web3游戏“Satorspace” ,并上线Huobi
- Number of exchanges in the 9th Blue Bridge Cup finals
- mysql实现两个字段合并成一个字段查询
- 命令模式 - Unity
- Enum + Validation 的个人最佳实践 demo 分享
- L1-027 出租(Lua)
- Sator推出Web3遊戲“Satorspace” ,並上線Huobi
- 本周小贴士#136:无序容器
猜你喜欢
本周小贴士#136:无序容器
命令模式 - Unity
Several best practices for managing VDI
第3章业务功能开发(用户登录)
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
Reflections on "product managers must read: five classic innovative thinking models"
麒麟信安中标国网新一代调度项目!
Devops' operational and commercial benefits Guide
redis主从、哨兵主备切换搭建一步一步图解实现
随机推荐
Reflections on "product managers must read: five classic innovative thinking models"
On Apache Doris Fe processing query SQL source code analysis
【网络攻防原理与技术】第5章:拒绝服务攻击
麒麟信安云平台全新升级!
麒麟信安中标国网新一代调度项目!
Solidity 开发环境搭建
Rpcms method of obtaining articles under the specified classification
mysql实现两个字段合并成一个字段查询
How to add aplayer music player in blog
Skimage learning (2) -- RGB to grayscale, RGB to HSV, histogram matching
Shallow understanding Net core routing
本周小贴士#141:注意隐式转换到bool
L1-025 正整数A+B(Lua)
Linux 安装mysql8.X超详细图文教程
First in China! Todesk integrates RTC technology into remote desktop, with clearer image quality and smoother operation
简单的loading动画
【TPM2.0原理及应用指南】 16、17、18章
电脑无法加域,ping域名显示为公网IP,这是什么问题?怎么解决?
LeetCode刷题day49
LeetCode 890(C#)