依赖:(注意minSdkVersion是19,少于会报错)
dependencies {
compile 'com.sdsmdg.harjot:rotatingtext:1.0.1'
}
示例:
XML
<com.sdsmdg.harjot.rotatingtext.RotatingTextWrapper
android:id="@+id/custom_switcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Java
RotatingTextWrapper rotatingTextWrapper = (RotatingTextWrapper) findViewById(R.id.custom_switcher);
rotatingTextWrapper.setSize(35);
Rotatable rotatable = new Rotatable(Color.parseColor("#FFA036"), 1000, "Word", "Word01", "Word02");
rotatable.setSize(35);
rotatable.setAnimationDuration(500);
rotatingTextWrapper.setContent("This is ?", rotatable);
结果
更多方法
RotatingTextWrapper
属性 | 功能 | 描述 |
---|---|---|
内容 | setContent(...) | 设置实际内容。由一个字符串和Rotatables阵列组成。 |
字体 | setTypeface(...) | 设置非旋转文本的字体 |
尺寸 | 的setSize(...) | 设置非旋转文本的大小 |
暂停 | 暂停(x)的 | 暂停'第X个可旋转的方法 |
恢复 | 恢复(X) | 恢复“可旋转”的方法 |
可旋转
属性 | 功能 | 描述 |
---|---|---|
颜色 | 的setColor(...) | 设置与可旋转相关联的旋转文本的颜色 |
尺寸 | 的setSize(...) | 设置与可旋转相关的旋转文本的大小 |
字体 | setTypeface(...) | 设置与该可旋转相关联的旋转文本的字体 |
插补 | setInterpolator(...) | 设置切换文本时使用的动画插值器 |
更新持续时间 | setUpdateDuration(...) | 设置切换字之间的间隔 |
动画持续时间 | setAnimationDuration(...) | 设置切换动画的持续时间 |
中心对齐 | setCenter(...) | 将旋转文本对齐到textview的中心,如果设置为 true |