progress-bar 相关问题

进度条是图形用户界面中的组件,用于传达任务的进度,例如下载或文件传输。

如何在Android中使用PlayerView的DefaultTimeBar outSide

我正在使用playerview,我想显示视频的进度。所以我使用了PlayerView并在playerview下面使用了LinearLayout,在LinearLayout内部我使用了PlayerView 我正在使用播放器视图,我想显示视频的进度。所以我使用了PlayerView并在playerview下面使用了LinearLayout,在LinearLayout内部我使用了PlayerView但是我不知道如何将它与Playerview连接。我不想在 Playerview 上有任何控件,它应该在playerview之外。 我的代码如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:orientation="vertical"> <com.google.android.exoplayer2.ui.PlayerView android:id="@+id/videoView" android:layout_width="match_parent" android:layout_height="300dp" android:layout_marginLeft="50dp" android:layout_marginRight="50dp" android:background="@android:color/white" android:visibility="visible"> </com.google.android.exoplayer2.ui.PlayerView> <com.google.android.exoplayer2.ui.DefaultTimeBar android:id="@+id/exo_progress1" style="@style/Base.Widget.AppCompat.SeekBar" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> 这是我的要求 对于这种情况我有一个解决方法。这个想法是,您仍然将 DefaultTimeBar 放在 PlayerView 控制器布局内,然后手动将 DefaultTimeBar 视图移动到 PlayerView 外部,对于您的情况,它位于 LinearLayout 中。 R.layout.main <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/mainView" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:orientation="vertical"> <com.google.android.exoplayer2.ui.PlayerView android:id="@+id/videoView" android:layout_width="match_parent" android:layout_height="300dp" android:layout_marginLeft="50dp" android:layout_marginRight="50dp" android:background="@android:color/white" app:controller_layout_id="@layout/exo_playback_control_view" /> </LinearLayout> R.layout.exo_playback_control_view <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.exoplayer2.ui.DefaultTimeBar android:id="@+id/exo_progress" style="@style/Base.Widget.AppCompat.SeekBar" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout> 然后,在您的活动/片段中的某个位置,手动移动视图(例如,我在这里使用 Kotlin)。 val mainView = findViewById<LinearLayout>(R.id.mainView) val videoView = findViewById<PlayerView>(R.id.videoView) val defaultTimeBarView = videoView.findViewById<DefaultTimeBar>(R.id.exo_progress) val parent = defaultTimeBarView.parent as? ViewGroup parent?.removeView(defaultTimeBarView) mainView.addView(defaultTimeBarView) 但是,如果 PlayerView 的控制器视图可见性被隐藏,则进度条上仍然有奇怪的动画,但如果它可见,则进度条可以工作。

回答 1 投票 0

如何使用 C# 和 WPF 创建圆形进度条选框并仅填充进度条的灰色区域

我创建了一个自定义的圆形进度条,如下图: 使用以下代码: 我创建了一个自定义的圆形进度条,如下图: 使用以下代码: <UserControl x:Class="WpfApp1.SpinnerProgressBar" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> <Viewbox> <Canvas Width="100" Height="100"> <!-- Base Spinner --> <Path Stroke="LightGray" StrokeThickness="3" Fill="LightGray" Data="M 0 100 a 100,100 0 1 1 200,0 a 100,100 0 1 1 -200,0 M 30 100 a 70,70 0 1 1 140,0 a 70,70 0 1 1 -140,0" RenderTransformOrigin="0.5,0.5" /> <!-- Loader Spinner "M 0 100 a 100,100 0 0 1 100,-100 v 30 a 70,70 0 0 0 -70,70" --> <Path Fill="Gold" Data="M 0 100 a 100,100 0 0 1 100,-100 v 30 a 70,70 0 0 0 -70,70" RenderTransformOrigin="1,1" > <Path.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="0"/> <TranslateTransform/> </TransformGroup> </Path.RenderTransform> </Path> </Canvas> </Viewbox> </UserControl> 通过模仿选框行为,我只需要绑定到<RotateTransform Angle="0"/>(如果我没记错的话)。但是,当存在成功连接到数据库以及仍尝试连接时带有选框的情况时,我陷入了如何创建完整进度条的部分。我怎样才能完成完整的进度条部分?如果有教程/视频可以解释如何操作,我将不胜感激。 为 Marquee 效果制作旋转动画非常简单,只需为 RenderTransform.RotateTranform 属性设置动画即可。 你可以像这样实现它。这是 Storyboard 的声明,带有一些额外的旋转效果,以及由 IsMouseOver 在选定的 Path 上触发的示例。 <UserControl.Resources> <Storyboard x:Key="SpinStoryboardSpinning" RepeatBehavior="Forever"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Path.RenderTransform).(RotateTransform.Angle)"> <EasingDoubleKeyFrame KeyTime="0:0:0" Value="90"/> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="180"/> <EasingDoubleKeyFrame KeyTime="0:0:1" Value="450"> <EasingDoubleKeyFrame.EasingFunction> <QuadraticEase EasingMode="EaseInOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> </Storyboard> </UserControl.Resources> <Path Fill="Gold" Data="M 0 100 a 100,100 0 0 1 100,-100 v 30 a 70,70 0 0 0 -70,70" RenderTransformOrigin="1,1"> <Path.RenderTransform> <RotateTransform Angle="90"/> </Path.RenderTransform> <Path.Style> <Style TargetType="{x:Type Path}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource SpinStoryboardSpinning}"/> </Trigger.EnterActions> </Trigger> </Style.Triggers> </Style> </Path.Style> </Path> 但是要创建完整的进度条,这是更复杂的任务。 首先,您需要控制创建的Storyboards,即在需要时停止和启动它们。另外,对于 ProgressBar 本身,我建议首先从 ProgressBar 控件派生并根据需要设置其样式。 好的开始是首先创建 standard,但基于 MSDN 中的此示例设计 ProgressBar https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/progressbar-styles -和-模板?view=netframeworkdesktop-4.8 圆形进度条示例。 自定义控件和转换器: using System; using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Markup; using System.Windows.Media; using static System.Math; namespace Core2023.RoundProgressBar { public class RoundProgressBar : RangeBase { static RoundProgressBar() { DefaultStyleKeyProperty.OverrideMetadata(typeof(RoundProgressBar), new FrameworkPropertyMetadata(typeof(RoundProgressBar))); } } [ValueConversion(typeof(ProgressBar), typeof(Geometry))] public class ProgressBarToGeometryConverter : IMultiValueConverter { private static readonly double valPI = 2 * PI; public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { double min = (double)values[0]; double max = (double)values[1]; double value = (double)values[2]; double angle = (value - min) / (max - min); angle *= valPI; if (!double.IsNormal(angle)) return DependencyProperty.UnsetValue; double cos = Cos(angle); double sin = Sin(angle); double x1 = 100 * cos + 100; double y1 = 100 * sin + 100; double x2 = 70 * cos + 100; double y2 = 70 * sin + 100; string data; if (angle < PI) { data = @$" M200,100 A100,100 0 0 1 {x1.ToString(culture)},{y1.ToString(culture)} L{x2.ToString(culture)},{y2.ToString(culture)} A070,070 0 0 0 170,100 z"; } else { data = @$" M200,100 A100,100 0 1 1 {x1.ToString(culture)},{y1.ToString(culture)} L{x2.ToString(culture)},{y2.ToString(culture)} A070,070 0 1 0 170,100 z"; } return Geometry.Parse(data); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } private ProgressBarToGeometryConverter() { } public static ProgressBarToGeometryConverter Instance { get; } = new(); } [MarkupExtensionReturnType(typeof(ProgressBarToGeometryConverter))] public class ProgressBarToGeometryExtension : MarkupExtension { public override object ProvideValue(IServiceProvider serviceProvider) { return ProgressBarToGeometryConverter.Instance; } } } 主题 Generic.xaml: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Core2023" xmlns:rpb="clr-namespace:Core2023.RoundProgressBar"> <Style TargetType="{x:Type rpb:RoundProgressBar}"> <Setter Property="Background" Value="LightGray"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type rpb:RoundProgressBar}"> <ControlTemplate.Resources> <Geometry x:Key="round"> M 0 100 a 100,100 0 1 1 200,0 a 100,100 0 1 1 -200,0 M 30 100 a 70,70 0 1 1 140,0 a 70,70 0 1 1 -140,0</Geometry> </ControlTemplate.Resources> <Grid> <!-- Base Spinner --> <Path Fill="{TemplateBinding Background}" Data="{StaticResource round}"/> <Path Stroke="{TemplateBinding BorderBrush}" StrokeThickness="3" Data="{StaticResource round}" Panel.ZIndex="2"/> <!-- Loader Spinner "M 0 100 a 100,100 0 0 1 100,-100 v 30 a 70,70 0 0 0 -70,70" --> <Path Fill="Gold"> <Path.Data> <MultiBinding Converter="{rpb:ProgressBarToGeometry}"> <Binding RelativeSource="{RelativeSource AncestorType=rpb:RoundProgressBar}" Path="Minimum"/> <Binding RelativeSource="{RelativeSource AncestorType=rpb:RoundProgressBar}" Path="Maximum"/> <Binding RelativeSource="{RelativeSource AncestorType=rpb:RoundProgressBar}" Path="Value"/> </MultiBinding> </Path.Data> </Path> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> 带有 Value 属性的使用和动画示例的窗口: <Window x:Class="Core2023.RoundProgressBar.RoundProgressBarWindow" 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:Core2023.RoundProgressBar" mc:Ignorable="d" Title="RoundProgressBarWindow" Height="450" Width="800"> <Window.Triggers> <EventTrigger RoutedEvent="Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Duration="0:0:5" To="10" Storyboard.TargetName="rpb" Storyboard.TargetProperty="Value"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Window.Triggers> <Grid> <local:RoundProgressBar x:Name="rpb" Maximum="10" Minimum="-10" Value="-10" BorderBrush="Aqua"/> </Grid> </Window> Value 属性可以绑定到 ViewModel 或以任何其他方式设置。进度将正确显示。 P.S. 根据 Clements 的评论,我提供了使用 StreamGeometry 的转换器的改进版本。 [ValueConversion(typeof(ProgressBar), typeof(Geometry))] public class ProgressBarToGeometryConverter : IMultiValueConverter { private static readonly double valPI = 2 * PI; public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { double min = (double)values[0]; double max = (double)values[1]; double value = (double)values[2]; if (value == max) { } double angle = (value - min) / (max - min); angle *= valPI; if (!double.IsNormal(angle)) return DependencyProperty.UnsetValue; double cos = Cos(angle); double sin = Sin(angle); double x1 = 100 * cos + 100; double y1 = 100 * sin + 100; double x2 = 70 * cos + 100; double y2 = 70 * sin + 100; StreamGeometry sg = new(); sg.FillRule = FillRule.EvenOdd; using StreamGeometryContext sgc = sg.Open(); if (value >= max) { sgc.BeginFigure(new Point(200, 100), true, true); sgc.ArcTo(new Point(0, 100), new Size(100, 100), 0, false, SweepDirection.Clockwise, true, false); sgc.ArcTo(new Point(200, 100), new Size(100, 100), 0, false, SweepDirection.Clockwise, true, false); sgc.LineTo(new Point(170, 100), true, false); sgc.ArcTo(new Point(30, 100), new Size(070, 070), 0, false, SweepDirection.Counterclockwise, true, false); sgc.ArcTo(new Point(170, 100), new Size(070, 070), 0, false, SweepDirection.Counterclockwise, true, false); } else if (angle < PI) { sgc.BeginFigure(new Point(200, 100), true, true); sgc.ArcTo(new Point(x1, y1), new Size(100, 100), 0, false, SweepDirection.Clockwise, true, false); sgc.LineTo(new Point(x2, y2), true, false); sgc.ArcTo(new Point(170, 100), new Size(070, 070), 0, false, SweepDirection.Counterclockwise, true, false); } else { sgc.BeginFigure(new Point(200, 100), true, true); sgc.ArcTo(new Point(x1, y1), new Size(100, 100), 0, true, SweepDirection.Clockwise, true, false); sgc.LineTo(new Point(x2, y2), true, false); sgc.ArcTo(new Point(170, 100), new Size(070, 070), 0, true, SweepDirection.Counterclockwise, true, false); } return sg; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } private ProgressBarToGeometryConverter() { } public static ProgressBarToGeometryConverter Instance { get; } = new(); }

回答 2 投票 0

如何在长时间的服务器进程中显示信息丰富的实时进度数据

我的流程很长,可能需要1个小时。 这个过程由每年运行的许多步骤组成。我的主要问题是: 如何在...期间向最终用户提供信息丰富的实时进度

回答 4 投票 0

在 BackGroundWorker 中运行方法并显示进度条

我想要的是,当某些方法正在执行某些任务时,UI 保持其自身处于活动状态,并且我想在进度栏中显示工作进度。 我有一个方法,一个 BackGroundWorker 和一个 Progressbar。我是...

回答 3 投票 0

VB在程序检查数据库时自动上升进度条

我是编码新手,但是当我的程序检查数据库时需要很长时间。我的客户想要一个进度条,当程序运行代码时进度条会上升,这样他就可以看到他需要等待多长时间......

回答 1 投票 0

在 Odoo 16 中动态更改进度条的颜色

我想更改瞬态模型中 one2many 行中进度条的颜色。 我的想法是从进度条小部件创建一个自定义小部件,然后添加一个获取...

回答 1 投票 0

带有工具提示的引导进度条作为图例

我创建了一个引导工具栏,其中包含不同样式的多个部分。现在我想添加一个用作图例的工具提示,解释不同样式代表什么。但款式确实...

回答 1 投票 0

如何在WinUi 3中更改ProgressBarTrackHeight高度?

我想改变WinUI-3中进度条的ProgressBarTrackHeight的高度。我不知道该怎么做,请帮我提供一个代码示例。 我想改变WinUI-3中进度条的ProgressBarTrackHeight的高度。我不知道该怎么做,请帮我提供一个代码示例。 <ProgressBar Width="130" Value="30" /> GitHub 存储库中有一个问题。 作为解决方法,您可以创建自定义 ProgressBar: public class ProgressBarEx : ProgressBar { protected override void OnApplyTemplate() { base.OnApplyTemplate(); foreach (Grid grid in this.FindDescendants().OfType<Grid>()) { grid.Height = Height; } } } 现在 Height 属性应该可以正常工作了: <local:ProgressBarEx Height="50" Width="130" Value="30" /> 请注意 FindDescendants 来自 CommunityToolkit.WinUI.Extensions NuGet 包。

回答 1 投票 0

如何使用 Angular 的 HTML 进度条

如何在 Angular 中使用 HTML 内置进度条: 文件进度: 30% 如何在 Angular 中使用 HTML 内置进度条: <label for="file">File progress:</label> <progress id="file" max="100" value="70">30%</progress> 我的意思是如何从角度分量动态改变value。有什么想法吗? 要在 Angular 中执行此操作,您可以使用“数据绑定”。 在 Angular 组件 TS 文件中,创建一个变量来存储当前进度: progressValue: number = 30; 然后直接插入值进去,这样就动态了,如下: <label for="file">File progress:</label> <progress id="file" max="100" [value]="progressValue">{{ progressValue }}%</progress> 如果要更改进度条,则将在 TS 文件中更改该变量。 参考:https://angular.io/guide/binding-syntax

回答 1 投票 0

C# WPF 中沿轮廓带有进度条的矩形按钮

我需要在 C# 6.0 WPF 中创建一个带圆角的矩形按钮。这个按钮应该有一个进度条,而不是一个顺时针填充的框架(从顶部边框的中间开始)...

回答 1 投票 0

写入标准输出时保持进度条可见

我有一个 PowerShell 安装脚本,它会调用其他几个脚本,这些脚本会在运行过程中写入 stdout。无法确定安装脚本已经进行了多远...

回答 1 投票 0

如何停止循环进度条旋转?

我的 xml 中有一个进度条。它一直在旋转。 我的 xml 中有一个进度条。它一直在旋转。 <ProgressBar android:id="@+id/progressBar" style="?android:attr/progressBarStyle" android:layout_width="167dp" android:layout_height="170dp" android:layout_gravity="center" android:layout_marginBottom="48dp" /> 有办法让它停止旋转吗?将其设置为圆形(就好像加载了%100)。 我尝试设置进度参数但没有任何改变。 是否有可能或者我应该制作一个自定义进度条? 这种情况是由于使用了默认的不确定样式(android:style="?android:attr/progressBarStyle")造成的。 此样式用于没有已知完成持续时间的进度条。 试试这个 style="?android:attr/progressBarStyleHorizontal" 您现在可以设置 val progressBar: ProgressBar = findViewById(R.id.progressBar) progressBar.progress = 50 如果您仍希望其为圆形,则需要创建自定义进度条。

回答 1 投票 0

圆形进度指示器的自定义形状

我知道我可以有一个 CircularProgressIndicator 来指示一些进度,但我也可以给它一个自定义形状,如下所示: 目标将是一个半圆,带有一些遗漏的元素,但仍然......

回答 1 投票 0

从活动部分隐藏适配器中的进度条

我的适配器部分有一个进度条,我想从活动部分更改它。 适配器 接口PreparedOnItemDetailClickListener { 有趣的点击( 订单详情:

回答 1 投票 0

如何将进度条(例如tqdm)附加到f.write()?

with open("./output/" + 文件名 + ".txt", "w") as f: f.write(非常长的字符串) 我有一个很长的字符串,我必须写入文件,我想附上一个

回答 1 投票 0

获取 FTP 服务器上的文件大小并将其放在标签上

我正在尝试获取托管在 FTP 服务器上的文件的大小,并将其放入标签中,同时“BackgroundWorker”在后台工作。 我使用“尝试”来获取该值,但该值是

回答 1 投票 0

带有可停止线程的CustomTkinter进度条

我正在尝试将 https://stackoverflow.com/a/75728288/7611214 中的 ctk 进度条合并到像 https://stackoverflow.com/a/325528/7611214 这样可停止的线程上。我想我已经很接近了,但我...

回答 1 投票 0

如何在备份脚本中实现进度条

我有一个脚本,可以对整个系统进行备份,但我看不到它的进度。我找到了许多带有进度条脚本的答案,但我不知道如何将它们实现到我的备份中

回答 2 投票 0

CSS进度条宽度由内联样式设置,未应用

我的CSS进度条渲染除内联样式之外的所有内容,因此进度内容的大小不会按预期动态变化。 {{ field_ct_rack_left_pdu__...

回答 1 投票 0

Node.JS async.parallel 不会等到所有任务完成

我正在使用 aync.parallel 并行运行两个函数。这些函数请求 RSS 源。然后 RSS 提要被解析并添加到我的网页中。 但由于某种原因 async.parallel 运行调用...

回答 3 投票 0

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