Rol*_*and 5 android android-layout
我有一个带有ProgressBar的布局(实际上它是一个SeekBar但是ProgressBar会出现同样的问题).它工作正常,直到我开始动画整个布局,将其翻译下来.在动画期间,ProgressBar继续按预期工作,但是当动画完成时(我使用Animation.setFillAfter(true)将布局冻结在动画的最终位置),ProgressBar会正确停止更新,而只是一小行栏的顶部不断更新,而progressBar的底部保持冻结(它是一个水平的progressBar).
一些代码:使用ProgressBar的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/video_buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left">
<SeekBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/progressbar_Horizontal"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
/>
Run Code Online (Sandbox Code Playgroud)
这是我定义动画的地方:
Animation a = AnimationUtils.loadAnimation(this, R.anim.translate_down);
a.setFillAfter(true);
Run Code Online (Sandbox Code Playgroud)
这是我在整个布局上开始动画的地方:
View vv = p.findViewById(R.id.video_buttons);
vv.startAnimation(anim);
Run Code Online (Sandbox Code Playgroud)
我的第一个想法是您可能无意中使用了“android:secondaryProgress”属性。
除此之外,如果您在单独的线程中运行它,请确保您使用以下内容:
activity.runOnUiThread(new Runnable() //
{
public void run() //
{
int newProgressVal = Integer
.parseInt((String) syncProgressNumber.getText()) + 1;
syncProgress.incrementProgressBy(1);
syncProgressNumber.setText(String
.valueOf(newProgressVal));
}
});
Run Code Online (Sandbox Code Playgroud)
UI 线程不是线程安全的,因此您无法从其他线程更新 UI。
希望这可以帮助!
归档时间: |
|
查看次数: |
867 次 |
最近记录: |