简易设置滚动广告

依赖:(注意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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的 jQuery 代码示例,可以实现图片的无缝滚动: HTML 代码: ``` <div class="scroll-container"> <div class="scroll-wrapper"> <img src="image1.jpg" alt="Image 1"> <img src="image2.jpg" alt="Image 2"> <img src="image3.jpg" alt="Image 3"> <img src="image4.jpg" alt="Image 4"> </div> </div> ``` CSS 代码: ``` .scroll-container { width: 100%; overflow: hidden; } .scroll-wrapper { display: flex; animation: scroll 20s linear infinite; } .scroll-wrapper img { width: 100%; height: auto; } @keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-100%); } } ``` jQuery 代码: ``` $(function() { // 获取图片数量 var count = $('.scroll-wrapper img').length; // 复制第一张图片并插入到最后 $('.scroll-wrapper img:first').clone().appendTo('.scroll-wrapper'); // 设置总宽度 var totalWidth = count * 100; $('.scroll-wrapper').css('width', totalWidth + '%'); // 每张图片的宽度 var itemWidth = 100 / count; $('.scroll-wrapper img').css('width', itemWidth + '%'); }); ``` 说明: 1. 首先,我们需要将所有图片放在一个包含 `overflow: hidden` 样式的容器中,这样才能隐藏超出容器宽度的部分。 2. 然后,使用 flexbox 布局来让所有图片排列在一行,并且设置一个动画来实现滚动效果。 3. 在 jQuery 中,我们需要获取图片数量、复制第一张图片并插入到最后、设置总宽度和每张图片的宽度等操作。 4. 最后,我们可以根据需要调整 CSS 样式和动画时间等参数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值