marquee 相关问题

一种非标准HTML元素,可以使文本自动滚动

Android TextView Marquee 不起作用

选框不适用于我的 TextView 请检查下面的代码 TextView 的 XML 代码 选框不适用于我的 TextView 请检查下面的代码 XML 代码 TextView <TextView android:id="@+id/mtextcash" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="30dp" android:ellipsize="marquee" android:fadingEdge="horizontal" android:gravity="center" android:marqueeRepeatLimit="marquee_forever" android:maxLength="5" android:scrollHorizontally="true" android:scrollbars="horizontal" android:singleLine="true" android:text="Simple application that shows how to use marquee, with a long text" android:textColor="@color/white" android:textColorHint="@color/white" android:textSize="25dp" /> 在 Activity OnCreate 中 TextView inputAvailableCash = (TextView) findViewById(R.id.mtextcash); inputAvailableCash.setSelected(true); 提前致谢 由于文本很长,并且只有在单行中编写文本时您的代码才能工作。要么添加 android:singleline="true" 在 xml 中或将您的 java 代码更改为。 TextView inputAvailableCash = (TextView) findViewById(R.id.mtextcash); inputAvailableCash.setSelected(true); inputAvailableCash.setSingleLine(true); 这肯定对你有用。 一旦尝试将这些参数放入您的 TextView - 它就有效 android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" 而且你还需要setSelected(true): my_TextView.setSelected(true); 在 TextView 上运行选取框的最低代码是 <TextView . . android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" /> 也不要忘记如下设置选择 textview.setSelected(true); 在xml文件中添加此属性 android:focusable="true" android:focusableInTouchMode="true" 对于选取框效果,宽度应始终为“match_parent”或静态(如 200dp...等)。并以编程方式将其设置为 setSelected true,就像您已经完成的那样,然后只需将其宽度设置为 xml 中的 match_parent 即可。 编辑的xml: <TextView android:id="@+id/mtextcash" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="30dp" android:ellipsize="marquee" android:fadingEdge="horizontal" android:gravity="center" android:marqueeRepeatLimit="marquee_forever" android:maxLength="5" android:scrollHorizontally="true" android:scrollbars="horizontal" android:singleLine="true" android:text="Simple application that shows how to use marquee, with a long text" android:textColor="@color/white" android:textColorHint="@color/white" android:textSize="25dp" /> 如果通过执行 match_parent 它会影响您的设计,那么您必须通过固定其宽度或其他方式来管理它。 根据您使用的 xml 代码 android:maxLength="5" 意味着仅输入 5 个字符,因此您可以将其宽度固定为 50dp 或任何其他静态大小。 嘿,检查此代码,但是当您的文本大小(即长度较长)时,选框工作。它在我这边工作。:) <TextView android:id="@+id/mywidget" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" android:textColor="#2086CA" android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." android:textAppearance="?android:attr/textAppearanceSmall" /> 希望这有帮助。:) <TextView android:id="@+id/mtextcash" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="30dp" android:ellipsize="marquee" android:gravity="center" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:singleLine="true" android:text="Simple application that shows how to use marquee, with a long text" android:textColor="@color/white" android:textColorHint="@color/white" android:textSize="25dp" /> 我错误地设置了 android:maxLines="1" 而不是使用 android:singleLine="true"。切换后,一切都按预期运行。

回答 8 投票 0

为什么我的无限选取框动画重启时不稳定,而不是平滑循环?

我的无限选取框动画遇到问题。每当到达终点时,它似乎不会平滑地过渡回起点,而是突然重新开始。 常量滚动...

回答 1 投票 0

在 python-vlc 中使用字幕的问题

这里完全是新手…… 我目前正在尝试使用 python-vlc 和 PyQt5(在 Mac 上)创建一个视频播放器,并且进展顺利...... 我的代码非常混乱和尴尬,并且充满了 awk...

回答 1 投票 0

无缝无限滚动文本选取框CSS/宽度问题

我正在尝试创建 HTML/CSS 滚动文本功能,但是我在它看起来无缝时遇到了一些问题。 滚动文本从右侧开始并正确滚动,但是当...

回答 1 投票 0

HTML Marquee 在一定长度后缩小

我正在尝试使用 HTML Marquee 在标题上创建简单的滚动文本。然而,根据当前的文本长度,在达到一定数量的文本后,容器似乎会缩小,从而剪切...

回答 1 投票 0

html 中的 marquee 标签适用于水平方向,但不适用于垂直方向

选框标签完美适用于水平方向,但是当我将其方向设置为向上或向下时,会发生的情况是图片仅向下滚动屏幕/页面的一半。我想让它滚动...

回答 3 投票 0

对移动设备上的选框横幅文本大小调整错误进行故障排除

我在我的网站上实现了以下滚动字幕横幅,它在桌面上完美运行,但是在移动设备上它将正确加载一秒钟,然后文本随机调整大小...

回答 1 投票 0

WPF 字幕文本动画

我可以使用 TranslateTransform 滚动文本,但是当动画接近完成时我希望它再次开始。像蛇一样:) 这就是我所拥有的: 我可以使用 TranslateTransform 滚动文本,但是当动画接近完成时,我希望它再次开始。像蛇一样:) 这就是我所拥有的: <StackPanel Orientation="Horizontal" Margin="0,0,0,0"> <StackPanel.RenderTransform> <TranslateTransform x:Name="transferCurreny" X="-40"/> </StackPanel.RenderTransform> <StackPanel.Triggers> <EventTrigger RoutedEvent="StackPanel.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation From="0" To="-900" Duration="00:00:10" Storyboard.TargetProperty="X" Storyboard.TargetName="transferCurreny" RepeatBehavior="Forever"/> </Storyboard> </BeginStoryboard> </EventTrigger> </StackPanel.Triggers> <TextBlock FontSize="25" x:Name="txtKron" Margin="10,0,7,0"/> </StackPanel> 这就是我想要的: 这样的事情应该可以解决问题。 您可以将 Canvas 添加到 StackPanel,其中 2 个 TextBlocks 一个设置为位置 0,一个设置为 ActualWidth 的 StackPanel,然后当第一个文本块超出屏幕时,另一个块将进入视野。 我使用Canvas的原因是因为Canvas是唯一真正支持ClipToBounds="false"的元素,这使得第二个TextBlock可见,即使它放置在Canvas本身的边界之外 如果您想从右向左滚动,我们还需要一个 IValueConverter 来获取正确的负值。 我还在 SizeChanged 上添加了事件触发器,因此如果调整窗口大小,动画值将正确更新。 代码: namespace WpfApplication9 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } } public class NegatingConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is double) { return -((double)value); } return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is double) { return +(double)value; } return value; } } } Xaml: <Window x:Class="WpfApplication9.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication9" Title="MainWindow" Height="83" Width="222" Name="UI" Tag="Tol Level"> <StackPanel Orientation="Horizontal" x:Name="stack"> <StackPanel.Resources> <local:NegatingConverter x:Key="NegatingConverter" /> <Storyboard x:Key="slide"> <DoubleAnimation From="0" To="{Binding Width, ElementName=canvas, Converter={StaticResource NegatingConverter}}" Duration="00:00:10" Storyboard.TargetProperty="X" Storyboard.TargetName="transferCurreny" RepeatBehavior="Forever"/> </Storyboard> </StackPanel.Resources> <StackPanel.RenderTransform> <TranslateTransform x:Name="transferCurreny" X="0"/> </StackPanel.RenderTransform> <StackPanel.Triggers> <EventTrigger RoutedEvent="StackPanel.Loaded"> <BeginStoryboard Storyboard="{StaticResource slide}" /> </EventTrigger> <EventTrigger RoutedEvent="StackPanel.SizeChanged"> <BeginStoryboard Storyboard="{StaticResource slide}" /> </EventTrigger> </StackPanel.Triggers> <Canvas x:Name="canvas" Width="{Binding ActualWidth, ElementName=stack}"> <TextBlock Text="StackOverflow" FontSize="25" x:Name="txtKron" Canvas.Left="0"/> <TextBlock Text="{Binding Text, ElementName=txtKron}" FontSize="25" Canvas.Left="{Binding Width, ElementName=canvas}"/> </Canvas> </StackPanel> </Window> 结果: 编辑:从左到右 <StackPanel Orientation="Horizontal" x:Name="stack"> <StackPanel.Resources> <local:NegatingConverter x:Key="NegatingConverter" /> <Storyboard x:Key="slide"> <DoubleAnimation From="0" To="{Binding Width, ElementName=canvas}" Duration="00:00:10" Storyboard.TargetProperty="X" Storyboard.TargetName="transferCurreny" RepeatBehavior="Forever"/> </Storyboard> </StackPanel.Resources> <StackPanel.RenderTransform> <TranslateTransform x:Name="transferCurreny" X="0"/> </StackPanel.RenderTransform> <StackPanel.Triggers> <EventTrigger RoutedEvent="StackPanel.Loaded"> <BeginStoryboard Storyboard="{StaticResource slide}" /> </EventTrigger> <EventTrigger RoutedEvent="StackPanel.SizeChanged"> <BeginStoryboard Storyboard="{StaticResource slide}" /> </EventTrigger> </StackPanel.Triggers> <Canvas x:Name="canvas" Width="{Binding ActualWidth, ElementName=stack}"> <TextBlock Text="StackOverflow" FontSize="25" x:Name="txtKron" Canvas.Left="0"/> <TextBlock Text="{Binding Text, ElementName=txtKron}" FontSize="25" Canvas.Left="{Binding Width, ElementName=canvas, Converter={StaticResource NegatingConverter}}"/> </Canvas> </StackPanel> 上面答案中的代码不会产生连续滚动。这是连续平滑滚动的代码。 XAML: <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <Canvas Margin="6,83,9,0" Name="ViewingBox" Background="YellowGreen" Height="35" VerticalAlignment="Top"> <Label Canvas.Left="263" Canvas.Top="-2" Height="49" Name="BoxOne" FontSize="20">I need breakfast.</Label> <Label Canvas.Left="263" Canvas.Top="-2" Height="49" HorizontalAlignment="Stretch" Name="BoxTwo" VerticalAlignment="Top" FontSize="20">You can have oranges and egg.</Label> </Canvas> </Grid> </Window> VB 代码背后: Imports System.Windows.Media.Animation Public Enum Texts BoxOne BoxTwo End Enum Class Window1 Private dubAnim As New DoubleAnimation() Private dubAnim2 As New DoubleAnimation() Private NewsTimer As New Windows.Threading.DispatcherTimer() Dim leadText As Texts = Texts.BoxOne Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded dubAnim.From = ViewingBox.ActualWidth dubAnim.To = -BoxOne.ActualWidth dubAnim.SpeedRatio = 0.05 AddHandler dubAnim.Completed, AddressOf dubAnim_Completed Timeline.SetDesiredFrameRate(dubAnim, 320) BoxOne.BeginAnimation(Canvas.LeftProperty, dubAnim) dubAnim2.From = ViewingBox.ActualWidth dubAnim2.To = -BoxTwo.ActualWidth dubAnim2.SpeedRatio = 0.05 Timeline.SetDesiredFrameRate(dubAnim2, 320) AddHandler dubAnim2.Completed, AddressOf dubAnim2_Completed AddHandler NewsTimer.Tick, AddressOf NewsTimer_Tick NewsTimer.Interval = New TimeSpan(0, 0, 0.9) NewsTimer.Start() End Sub Private Sub NewsTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Dim BoxOneLocation As Point = BoxOne.TranslatePoint(New Point(0, 0), ViewingBox) Dim BoxTwoLocation As Point = BoxTwo.TranslatePoint(New Point(0, 0), ViewingBox) If leadText = Texts.BoxOne Then Dim loc As Double = BoxOneLocation.X + BoxOne.ActualWidth If loc < ViewingBox.ActualWidth / 1.5 Then BoxTwo.BeginAnimation(Canvas.LeftProperty, dubAnim2) NewsTimer.Stop() End If Else Dim loc As Double = BoxTwoLocation.X + BoxTwo.ActualWidth If loc < ViewingBox.ActualWidth / 1.5 Then BoxOne.BeginAnimation(Canvas.LeftProperty, dubAnim) NewsTimer.Stop() End If End If End Sub Private Sub dubAnim_Completed(ByVal sender As Object, ByVal e As EventArgs) leadText = Texts.BoxTwo NewsTimer.Start() End Sub Private Sub dubAnim2_Completed(ByVal sender As Object, ByVal e As EventArgs) leadText = Texts.BoxOne NewsTimer.Start() End Sub End Class 扩展sa_ddam213的答案,这是对第一个动画(从右到左)的修改。这适用于长字符串。 :) <StackPanel Orientation="Horizontal" x:Name="stack" Grid.Column="0" Margin="0" > <StackPanel.Resources> <local1:NegatingConverter x:Key="NegatingConverter" /> <Storyboard x:Key="slide"> <DoubleAnimation From="{Binding ActualWidth, ElementName=stack}" To="{Binding ActualWidth, ElementName=txtKron, Converter={StaticResource NegatingConverter}}" Duration="00:00:30" Storyboard.TargetProperty="X" Storyboard.TargetName="transferCurreny2" RepeatBehavior="Forever"/> </Storyboard> </StackPanel.Resources> <Label Content="{Binding Path=RSSFeed}" x:Name="txtKron" Canvas.Left="0" Foreground="#E9D460" Padding="0" Margin="0" VerticalAlignment="Center"> <Label.Triggers> <EventTrigger RoutedEvent="Label.Loaded"> <BeginStoryboard Storyboard="{StaticResource slide}"/> </EventTrigger> <EventTrigger RoutedEvent="Label.SizeChanged"> <BeginStoryboard Storyboard="{StaticResource slide}"/> </EventTrigger> </Label.Triggers> <Label.RenderTransform> <TranslateTransform x:Name="transferCurreny2" X="0"/> </Label.RenderTransform> </Label> </StackPanel> 为了使此功能适用于比元素长的字符串,并隐藏溢出元素的文本,我进一步修改了之前的答案。 要直接使用它,首先创建一个名为 WpfApp1 的项目 xaml: <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <Border Width="200" HorizontalAlignment="Center" VerticalAlignment="Center" Height="25" ClipToBounds="True" BorderThickness="1.5" BorderBrush="Red"> <Border x:Name="stack"> <Border.Resources> <local:NegatingConverter x:Key="NegatingConverter" /> <local:MarqueeMargin x:Key="MarqueeMargin" /> <local:NegMarqueeMargin x:Key="NegMarqueeMargin" /> <Storyboard x:Key="slide"> <DoubleAnimation From="0" To="{Binding ActualWidth, ElementName=txt_scroll, Converter={StaticResource NegMarqueeMargin}}" Duration="00:00:2" Storyboard.TargetProperty="X" Storyboard.TargetName="transferCurreny" RepeatBehavior="Forever"/> </Storyboard> </Border.Resources> <Border.RenderTransform> <TranslateTransform x:Name="transferCurreny" X="0"/> </Border.RenderTransform> <Border.Triggers> <EventTrigger RoutedEvent="StackPanel.Loaded"> <BeginStoryboard Storyboard="{StaticResource slide}" /> </EventTrigger> <EventTrigger RoutedEvent="StackPanel.SizeChanged"> <BeginStoryboard Storyboard="{StaticResource slide}" /> </EventTrigger> </Border.Triggers> <Canvas Width="{Binding ActualWidth, ElementName=stack}"> <TextBlock Text="This text is too long to fit in the parent element." FontSize="15" Foreground="#F00" x:Name="txt_scroll" Canvas.Left="0"/> <TextBlock Text="{Binding Text, ElementName=txt_scroll}" FontSize="15" Foreground="#F00" Canvas.Left="{Binding ActualWidth, ElementName=txt_scroll, Converter={StaticResource MarqueeMargin}}"/> </Canvas> </Border> </Border> </Grid> </Window> 此窗口的 C# 代码: <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <Border Width="200" HorizontalAlignment="Center" VerticalAlignment="Center" Height="25" ClipToBounds="True" BorderThickness="1.5" BorderBrush="Red"> <Border x:Name="moving_border"> <Border.Resources> <local:NegatingConverter x:Key="NegatingConverter" /> <local:MarqueeMargin x:Key="MarqueeMargin" /> <local:NegMarqueeMargin x:Key="NegMarqueeMargin" /> <Storyboard x:Key="slide"> <DoubleAnimation From="0" To="{Binding ActualWidth, ElementName=txt_scroll, Converter={StaticResource NegMarqueeMargin}}" Duration="00:00:2" Storyboard.TargetProperty="X" Storyboard.TargetName="transferCurreny" RepeatBehavior="Forever"/> </Storyboard> </Border.Resources> <Border.RenderTransform> <TranslateTransform x:Name="transferCurreny" X="0"/> </Border.RenderTransform> <Border.Triggers> <EventTrigger RoutedEvent="Border.Loaded"> <BeginStoryboard Storyboard="{StaticResource slide}" /> </EventTrigger> <EventTrigger RoutedEvent="Border.SizeChanged"> <BeginStoryboard Storyboard="{StaticResource slide}" /> </EventTrigger> </Border.Triggers> <Canvas Width="{Binding ActualWidth, ElementName=moving_border}"> <TextBlock Text="This text is too long to fit in the parent element." FontSize="15" Foreground="#F00" x:Name="txt_scroll" Canvas.Left="0"/> <TextBlock Text="{Binding Text, ElementName=txt_scroll}" FontSize="15" Foreground="#F00" Canvas.Left="{Binding ActualWidth, ElementName=txt_scroll, Converter={StaticResource MarqueeMargin}}"/> </Canvas> </Border> </Border> </Grid> </Window> 这是 Leon Munir 的答案的 C# 版本。 MainWindow.xaml <Window x:Class="TextAnimation.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:TextAnimation" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <Canvas Margin="6,83,9,0" Name="ViewingBox" Background="YellowGreen" Height="35" VerticalAlignment="Top"> <Label Canvas.Left="263" Canvas.Top="-2" Height="49" Name="BoxOne" FontSize="20">I need breakfast.</Label> <Label Canvas.Left="263" Canvas.Top="-2" Height="49" HorizontalAlignment="Stretch" Name="BoxTwo" VerticalAlignment="Top" FontSize="20">You can have oranges and egg.</Label> </Canvas> </Grid> </Window> MainWindow.xaml.cs using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media.Animation; namespace TextAnimation { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private DoubleAnimation dubAnim = new DoubleAnimation(); private DoubleAnimation dubAnim2 = new DoubleAnimation(); private System.Windows.Threading.DispatcherTimer NewsTimer = new System.Windows.Threading.DispatcherTimer(); private Texts leadText = Texts.BoxOne; public MainWindow() { InitializeComponent(); Loaded += Window1_Loaded; } private void Window1_Loaded(object sender, System.Windows.RoutedEventArgs e) { dubAnim.From = ViewingBox.ActualWidth; dubAnim.To = -BoxOne.ActualWidth; dubAnim.SpeedRatio = 0.05d; dubAnim.Completed += DubAnim_Completed; Timeline.SetDesiredFrameRate(dubAnim, 320); BoxOne.BeginAnimation(Canvas.LeftProperty, dubAnim); dubAnim2.From = ViewingBox.ActualWidth; dubAnim2.To = -BoxTwo.ActualWidth; dubAnim2.SpeedRatio = 0.05d; Timeline.SetDesiredFrameRate(dubAnim2, 320); dubAnim2.Completed += DubAnim2_Completed; NewsTimer.Tick += NewsTimer_Tick; NewsTimer.Interval = new TimeSpan(0, 0, (int)Math.Round(0.9)); NewsTimer.Start(); } private void NewsTimer_Tick(object sender, EventArgs e) { Point BoxOneLocation = BoxOne.TranslatePoint(new Point(0, 0), ViewingBox); Point BoxTwoLocation = BoxTwo.TranslatePoint(new Point(0, 0), ViewingBox); if (leadText == Texts.BoxOne) { double loc = BoxOneLocation.X + BoxOne.ActualWidth; if (loc < ViewingBox.ActualWidth / 1.5d) { BoxTwo.BeginAnimation(Canvas.LeftProperty, dubAnim2); NewsTimer.Stop(); } } else { double loc = BoxTwoLocation.X + BoxTwo.ActualWidth; if (loc < ViewingBox.ActualWidth / 1.5d) { BoxOne.BeginAnimation(Canvas.LeftProperty, dubAnim); NewsTimer.Stop(); } } } private void DubAnim_Completed(object sender, EventArgs e) { leadText = Texts.BoxTwo; NewsTimer.Start(); } private void DubAnim2_Completed(object sender, EventArgs e) { leadText = Texts.BoxOne; NewsTimer.Start(); } } } 文本.cs namespace TextAnimation { public enum Texts { BoxOne, BoxTwo } } 我从下面的链接中找到了一个更简单的选框文本(仅适用于我的情况,所以请先尝试一下),对于更多类似向上和向下的内容,您可以检查链接 https://www.codeproject.com/Articles/48267/Making-a-Simple-Marquee-Text-Control-Drip-Animatio 详情可以查看以下图片: xaml: <Canvas ClipToBounds="True" Name="canMain" VerticalAlignment="Center" Background="YellowGreen" Height="35"> <TextBlock Name="tbmarquee" Text="Testing 123~ Testing 123~ Testing 123~" FontSize="24" FontWeight="Bold" Foreground="Black"></TextBlock> </Canvas> C#代码 从左到右 private void LeftToRightMarquee() { double height = canMain.ActualHeight - tbmarquee.ActualHeight; tbmarquee.Margin = new Thickness(0, height / 2, 0, 0); DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.From = -tbmarquee.ActualWidth; doubleAnimation.To = canMain.ActualWidth; doubleAnimation.RepeatBehavior = RepeatBehavior.Forever; doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(_marqueeTimeInSeconds)); tbmarquee.BeginAnimation(Canvas.LeftProperty, doubleAnimation); } 从右到左 private void RightToLeftMarquee() { double height = canMain.ActualHeight - tbmarquee.ActualHeight; tbmarquee.Margin = new Thickness(0, height / 2, 0, 0); DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.From = -tbmarquee.ActualWidth; doubleAnimation.To = canMain.ActualWidth; doubleAnimation.RepeatBehavior = RepeatBehavior.Forever; doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(_marqueeTimeInSeconds)); tbmarquee.BeginAnimation(Canvas.RightProperty, doubleAnimation); }

回答 6 投票 0

字幕在狩猎中落后

我们在我们的网站上使用选框标签。 但当我们对其进行错误测试时,它在手机上的 safari 中出现了滞后。有没有办法减少延迟?它在 Chrome 中运行良好。

回答 2 投票 0

w3c 验证中的 html 5 marquee 标记错误

我在选框标签中有一些文字。 测试测试测试测试测试 我正在使用 html 5 和 css 3。当我在 w3c 验证器中检查我的 html 时,它

回答 3 投票 0

Prolog 中的字幕

从 html 中众所周知,marquee 显然是语义网的顶峰。或者更确切地说,它的最低点与闪烁标签并排。无论如何,我们如何在 Prolog 中表示选取框?换句话说,...

回答 1 投票 0

我正在尝试在反应中显示硬币市值的选取框小部件,但它不起作用

我正在使用 React 制作一个投资网站,我正在尝试使用 coinmarketcap 的小部件,但它似乎没有做任何事情 从“反应”导入反应 const Coinwidget = () => { 返回...

回答 0 投票 0

垂直滚动时水平滑动div——浏览器渲染

我有一个滑动效果的功能示例(如下),但它似乎在浏览器中呈现得很奇怪。有时字母看起来像是分开的。有时看起来它们的一部分是静止的......

回答 1 投票 0

On Scroll Text - 当页面重新加载时导致大的转变(跳跃)

我正在尝试创建滚动页面时移动的选取框文本,目前我正在获得该功能,但是例如,如果我在某个位置重新加载页面,文本正在移动(j ...

回答 0 投票 0

我正在使用“react-fast-marquee”库在我的下一个 js 网络应用程序中渲染 2 个选框,但它在较小的设备上重叠

我正在使用“react-fast-marquee”库(https://www.npmjs.com/package/react-fast-marquee) 第一个是提供股票数据,名称,价格和价格变化。 和第二个......

回答 0 投票 0

如何让 CSS 动画在悬停时减速停止,并在鼠标离开时继续无限移动?

我正在尝试使用以下 CSS 样式创建选取框: @关键帧滚动{ 0% { 转换: translateX(0) } 100% { 变换:翻译(-100%) } } 动画:滚动 var(--duration) 线性

回答 1 投票 0

在多个标签页中获取垂直滚动字幕脚本

在一个特定的网页上,https:/www.aeternus.orgtry,为了发布一些荷兰语(NL)的报价,我安装了一个垂直滚动字幕脚本。在第一个选项卡中,这个脚本是 ...

回答 1 投票 0

安卓:如何同时显示多个侯车亭(两个侯车亭的焦点)。

我想在我的应用程序中显示2个marquees。但是只有一个一直在工作。如果我注释第一个,那么第二个就会工作。否则,第一个就会工作。或者说一次只有一个牌子被关注。...

回答 1 投票 4

在div中只在有溢出时使用marquee?

我想在div标签中滚动文本(marquee),只有当文本溢出时才滚动。我已经设置了marquee,并且使用了jQuery Marquee插件。一切都在漂亮的marquee工作,但我不'... ...

回答 2 投票 1

WinForms ProgressBar.MarqueeAnimationSpeed没有影响。

我有一个WinForms应用程序,其中包含一个使用ProgressBarStyle.Marquee的进度条。它工作得很好。我可以在一个线程上做一些工作,而marquee就像它应该做的那样做动画。...

回答 1 投票 1

© www.soinside.com 2019 - 2024. All rights reserved.