我想打电话给setProgressDrawable一个ProgressBar在我的RemoteViews
但是似乎没有成为一个setDrawable(<view_id>,<method>,<value>)对方法RemoveViews我试过setBitmap,但setProgressDrawable需要一个Drawable不Bitmap和setInt也不管用.
我想避免加载不同的小部件布局xml文件只是为了处理不同的颜色进度条.
我正在尝试在代码中添加进度条并使其确定:
progressBar = new ProgressBar(getActivity());
progressBar.setLayoutParams(layoutParams);
parent.addView(progressBar, index);
progressBar.setId(id.list_item_secondary);
progressBar.setProgressDrawable(getResources().getDrawable(drawable.progress_horizontal));
progressBar.setIndeterminate(false);
progressBar.setMax(100);
Run Code Online (Sandbox Code Playgroud)
之后progressBar.setIndeterminate(false),isIndeterminate仍然是真实的,进度保持显示不确定的圆圈.
我怎样才能确定它?
如何创建这样的弧形进度条动画
目前我已经使用 Canvas 绘制圆弧并使用 animateFloatAsState API 将动画添加到进度条。但第二张照片不是我的预期。
[
]
// e.g. oldScore = 100f newScore = 350f
// Suppose 250 points are into one level
@Composable
fun ArcProgressbar(
modifier: Modifier = Modifier,
oldScore: Float,
newScore: Float,
level: String,
startAngle: Float = 120f,
limitAngle: Float = 300f,
thickness: Dp = 8.dp
) {
var value by remember { mutableStateOf(oldScore) }
val sweepAngle = animateFloatAsState(
targetValue = (value / 250) * limitAngle, // convert the value to angle
animationSpec = tween(
durationMillis …Run Code Online (Sandbox Code Playgroud) android android-progressbar android-jetpack-compose jetpack-compose-animation compose-recomposition
我正在研究一个自定义的不确定微调器,我通过SDK浏览了一些指针,发现了由Google制作的不确定的微调器xml文件:
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner_black_16"
android:pivotX="50%"
android:pivotY="50%"
android:framesCount="12"
android:frameDuration="100" />
Run Code Online (Sandbox Code Playgroud)
当我在我自己的项目中使用它作为drawable时,我会得到关于android:framesCount和的错误android:framesDuration.在Google上查看了一段时间后,我发现了这个问题报告的链接.
我的问题是:是否有任何解决方法,所以我仍然可以使用android:framesCount和android:framesDuration?或者还有其他方法可以让我的自定义微调器旋转平滑吗?
android android-animation android-layout android-progressbar
我想知道如何将拇指设置在搜索栏的中心.不知道如何表达,所以我将添加图片的链接.第一个img是设计指南的搜索栏,下面是我的搜索栏.

(忽略了角落.我在捕获了imgs之后修复了.)起初,从设计师那里,我得到了两个单独的img文本,无论好坏.所以我结合了那些.我以为它会像拇指一样工作.但现在我得到的是这些结果......请帮帮我..谢谢!
drawable:progressbar_goodbad xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<gradient
android:startColor="#f5c0bd"
android:centerColor="#f5c0bd"
android:centerY="0.75"
android:endColor="#f5c0bd"
android:angle="270"/>
<padding android:left="10dp"
android:top="1dp"
android:right="10dp"
android:bottom="1dp"/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:startColor="#234"
android:centerColor="#234"
android:centerY="0.75"
android:endColor="#a24"
android:angle="90"/>
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:startColor="#fc9a94"
android:centerColor="#fc9a94"
android:centerY="0.75"
android:endColor="#fc9a94"
android:angle="90"/>
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
</clip>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
主要布局xml的一部分
<SeekBar
android:id="@+id/seekBar_fun" …Run Code Online (Sandbox Code Playgroud) 今天我开始将应用程序移植到Android L预览版,以便在最终产品发布时几乎准备就绪.我发现的一个问题是我不能在ActionBar上有一个不确定的进度条.它根本不显示并在logcat上抛出此错误:
E/PhoneWindow? Circular progress bar not located in current window decor
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码,该代码适用于<4.4:
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
Run Code Online (Sandbox Code Playgroud)
有没有办法让它在Android L中再次运行,还是应该使用外部ProgressBar?
android android-progressbar android-actionbar android-5.0-lollipop
我有一个这种结构的活动:
FrameLayout
ProgressBar
ViewStub
Run Code Online (Sandbox Code Playgroud)
ViewStub在一个单独的线程中膨胀一个Fragment.我需要的是在片段加载时显示进度.问题是,当存根膨胀时,ProgressBar没有旋转(在我的情况下大约半秒:它是一个沉重的碎片)我已经尝试了一切:显示/隐藏视图,无效,在ViewSwitchers中显示它们等等,没有一旦ViewStub膨胀,它开始旋转,就像ui在膨胀时被冻结但在另一个线程中执行它似乎没有改善.我该怎么办?
如何在每个Retrofit 2.0API调用上显示进度条,而无需在每个活动中创建进度条,显示和解除.进度条应该在 API被命中时显示,并且当我们得到响应onResponse或被onFailure调用时它应该被忽略.
我试过这个:
ProgressDialog mProgressDialog = new ProgressDialog(this);
mProgressDialog.setIndeterminate(true);
mProgressDialog.setMessage("Loading...");
mProgressDialog.show();
retrofitService.login(new SignInRequest(email, password),
new Callback<SignInResponse>() {
@Override
public void onResponse(Call<SignInResponse> call, Response<SignInResponse> response) {
if (mProgressDialog.isShowing())
mProgressDialog.dismiss();
}
@Override
public void onFailure(Call<SignInResponse> call, Throwable t) {
if (mProgressDialog.isShowing())
mProgressDialog.dismiss();
}
});
Run Code Online (Sandbox Code Playgroud)
但是每当我进行API调用时,这段代码都必须在任何地方粘贴.我不想要重复的代码.
创建了一个循环进度条,它与动画一起正常工作.但在尝试使用动态数据显示它时,进度条不会更新.
下面的代码工作正常
progrssBarObj = FindViewById<ProgressBar>(Resource.Id.progressBarSync);
ObjectAnimator animation = ObjectAnimator.OfInt(progrssBarObj, "progress", 0, 100); // see this max value coming back here, we animale towards that value
animation.SetDuration(3000); //in milliseconds
animation.SetInterpolator(new DecelerateInterpolator());
animation.Start();
Run Code Online (Sandbox Code Playgroud)
和AXML代码是
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_column="2"
android:id="@+id/progressBarSync"
android:layout_width="300dp"
android:layout_height="300dp"
android:progressDrawable="@drawable/circular_progress_bar"
android:background="@drawable/progress_bar_background" />
Run Code Online (Sandbox Code Playgroud)
但是当我在循环中尝试类似的东西时,进度条没有更新数据.基本上进度条没有在圆圈中更新.
for (int i = 0; i <= 100; i++)
{
int cnt = 0;
cnt = cnt + i;
progrssBarObj.Progress = cnt;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
问题
我想在这张图片中制作一个进度条:
期望的行为是:
到目前为止我发现了什么
我发现这篇文章可以说明我想要的东西.这种方法有什么问题吗?此外,该示例未显示如何自定义进度条(在我的情况下,我希望在带有弯角的视图顶部使用灰色).但我最想知道的是,该链接的方法是否合适.
我的猜测
我主要担心的是当请求到达时发生的"快速填充"但进度条尚未达到100%(我认为这将是大多数情况;请求不太可能达到100% ).考虑到链接中的内容,我在想,当请求到达时,该方法doSomeTasks应该在一个小间隔内返回进度条状态+ 1.因此,在示例中,如果它在55,它将返回56,57,58 ......直到100,并且返回将在它们之间具有间隔,例如0.5秒.这样,我想我可以模拟进度条快速增长到100%.
非常感谢任何帮助,谢谢!