android - 在加载主布局之前加载进度条布局
android - Load progress bar layout before loading main layout
我有一个带进度条的虚拟 RelativelayoutView。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/progressbar">
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/progressBar" />
</RelativeLayout>
当我的应用程序启动时,我需要这个 RelativelayoutView 出现 5 秒,并且应该消失,有或没有动画。
我不确定我是否理解你的问题,但我建议你在 activity:
中写下这样的内容
private Handler mHandler;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
mHandler = new Handler(Looper.getMainLooper());
mHandler.postDelayed(new Runnable() {
public void run() {
// hide your progress bar
findViewById(R.id.progressBar).setVisibility(View.GONE);
// or finish this activity and start a new one
startActivity(new Intent(MyActivity.this, MySecondActivity.class));
}
}, 5000);
}
@Override
public void onDestroy() {
super.onDestroy();
mHandler.removeCallbacks(null);
}
而且我认为您应该将 android:indeterminate="true"
属性添加到您的进度条。
希望对您有所帮助。干杯。
我有一个带进度条的虚拟 RelativelayoutView。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/progressbar">
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/progressBar" />
</RelativeLayout>
当我的应用程序启动时,我需要这个 RelativelayoutView 出现 5 秒,并且应该消失,有或没有动画。
我不确定我是否理解你的问题,但我建议你在 activity:
中写下这样的内容private Handler mHandler;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
mHandler = new Handler(Looper.getMainLooper());
mHandler.postDelayed(new Runnable() {
public void run() {
// hide your progress bar
findViewById(R.id.progressBar).setVisibility(View.GONE);
// or finish this activity and start a new one
startActivity(new Intent(MyActivity.this, MySecondActivity.class));
}
}, 5000);
}
@Override
public void onDestroy() {
super.onDestroy();
mHandler.removeCallbacks(null);
}
而且我认为您应该将 android:indeterminate="true"
属性添加到您的进度条。
希望对您有所帮助。干杯。