Java写字幕滚动_微信小程序实现自上而下字幕滚动

/**

页面的初始数据

*/

data: {

},/**

生命周期函数--监听页面加载

*/

onLoad: function (options) {

},/**

生命周期函数--监听页面初次渲染完成

*/

onReady: function () {

},/**

生命周期函数--监听页面显示

/

onShow: function () {

// this.util();

this.getHeight();

},util: function (obj) {

console.log(obj);

console.log(-obj.list);

var continueTime = (parseInt(obj.list / obj.container) + 1) 1500;

var setIntervalTime = 50 + continueTime;

var animation = wx.createAnimation({

duration: 200,//动画时长

timingFunction: "linear",//线性

delay: 0 //0则不延迟

});

this.animation = animation;

animation.translateY(obj.container).step({ duration: 50,timingFunction: 'step-start' }).translateY(-obj.list).step({ duration: continueTime });

this.setData({

animationData: animation.export()

})

setInterval(() => {

animation.translateY(obj.container).step({ duration: 50,timingFunction: 'step-start' }).translateY(-obj.list).step({ duration: continueTime });

this.setData({

animationData: animation.export()

})

},setIntervalTime)

// setInterval(() => {

// animation.translateY(50).step({ duration: 50,timingFunction: 'step-start' }).translateY(-250).step({ duration: 5000 });

// this.setData({

// animationData: animation.export()

// })

// },6000)

},getHeight() {

var obj = new Object();

//创建节点选择器

var query = wx.createSelectorQuery();

query.select('.container').boundingClientRect()

query.select('.list').boundingClientRect()

query.exec((res) => {

obj.container = res[0].height; // 框的height

obj.list = res[1].height; // list的height

// return obj;

this.util(obj);

})

}

})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
class ZiMupanel extends JFrame { public ZiMupanel() { Container con = this.getContentPane(); // 设置窗口名称 this.setTitle("滚动字幕"); // 设置布局管理器为 null ,方便 面板定位,一般使用null 布局时,将窗口设置不可改变大小 this.setLayout(null); // 设置窗口位置和大小 this.setBounds(300, 300, 460, 330); // 设置窗口可见 this.setVisible(true); // 设置不可改变大小 this.setResizable(false); // 设置当点击窗口的关闭按钮时退出 // 设置此窗体关闭,滚动面板不关闭 this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Panelfont1 p1 = new Panelfont1(); con.add(p1); p1.setBounds(15, 15, 175, 60); Panelfont2 p2 = new Panelfont2(); con.add(p2); p2.setBounds(195, 15, 250, 60); Panelneizi p3 = new Panelneizi(); con.add(p3); p3.setBounds(15, 80, 175, 80); Paneldirection p4 = new Paneldirection(); con.add(p4); p4.setBounds(195, 80, 250, 80); Panel5 p5 = new Panel5(); con.add(p5); p5.setBounds(15, 155, 430, 70); Panel6 p6 = new Panel6(); con.add(p6); p6.setBounds(15, 220, 430, 70); } } class Panelfont1 extends JPanel implements ActionListener{ public Panelfont1() { this.setBorder(BorderFactory.createTitledBorder("滚动字幕文字大小控制"));//设置 面板边框 this.setLayout(new GridLayout(1, 2)); bigfont = new JRadioButton("大字体", false); smallfont = new JRadioButton("小字体", true); bigfont.addActionListener(this); smallfont.addActionListener(this); ButtonGroup sexRadioButtonGroup = new ButtonGroup();// 创建一个选按钮组 sexRadioButtonGroup.add(bigfont);// 将单选按钮对象添加到按钮组中 sexRadioButtonGroup.add(smallfont);// 将单选按钮对象添加到按钮组中 //Enumeration elements = sexRadioButtonGroup.getElements();// 遍历按钮组中的所有按钮 this.add(bigfont); this.add(smallfont); } public void actionPerformed(ActionEvent e) { if(bigfont.isSelected()){ fontSize = 50; }else { fontSize = 36; } Font font = new Font(fontName,Font.BOLD,fontSize);
微信小程序中可以使用 `scroll-view` 组件来实现横向无缝滚动的效果。 首先,在 `scroll-view` 中添加一个 `view`,然后在这个 `view` 中添加多个要滚动的元素。这些元素可以通过 `flex` 布局来排列,同时设置宽度与高度。 为了实现无缝滚动,需要在 `view` 的最后再添加一次完整的元素列表,这样当滚动到最后一个元素时,就可以平滑地切换到第一个元素,从而实现无缝滚动的效果。 下面是一个示例代码: ```html <scroll-view scroll-x="true" style="white-space: nowrap;"> <view style="display: flex; flex-direction: row;"> <view style="width: 100px; height: 100px; background-color: red;"></view> <view style="width: 100px; height: 100px; background-color: green;"></view> <view style="width: 100px; height: 100px; background-color: blue;"></view> <view style="width: 100px; height: 100px; background-color: yellow;"></view> <view style="width: 100px; height: 100px; background-color: purple;"></view> <!-- 添加一次完整的元素列表 --> <view style="width: 100px; height: 100px; background-color: red;"></view> <view style="width: 100px; height: 100px; background-color: green;"></view> <view style="width: 100px; height: 100px; background-color: blue;"></view> <view style="width: 100px; height: 100px; background-color: yellow;"></view> <view style="width: 100px; height: 100px; background-color: purple;"></view> </view> </scroll-view> ``` 其中,`scroll-x="true"` 表示开启横向滚动,`white-space: nowrap;` 表示禁止换行。 通过这种方式,即可实现微信小程序中的横向无缝滚动
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值