Activity 이동 시, 로딩바를 띄워야 한다.
그러면, 로딩 중이라는 것을 인지하면 기다린다.
로딩바를 중앙에 띄워야 하겠지.
1)소스
mProgressDialog = new Dialog(mPreviewBaseActivity);
mProgressDialog.setContentView(R.layout.dialog_progressbar_center);
mProgressDialog.setCancelable(false);
//mProgressDialog.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
mProgressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
mProgressDialog.show();
2)Layout XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" >
<!-- style="@android:style/Widget.ProgressBar.Small" -->
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:background="@android:color/transparent"
android:visibility="gone"
android:indeterminate="true"
android:indeterminateTintMode="src_atop"
android:indeterminateTint="@color/storecamera_yellow"/>
/>
</RelativeLayout>
3)활용
private void goActivity(){
mProgressDialog.show();
goMoveActivity();
}
private void goMoveActivity(){
GomsLog.d(TAG, "goMoveActivity()");
final Intent intent = new Intent(mPreviewBaseActivity, GPUImageZoomCalibrationActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
final Pair<View, String> pair1 = Pair.create(findViewById(R.id.gpuimage), "tnGPUImage");
final Pair<View, String> pair2 = Pair.create(findViewById(R.id.tv_preview_top_title), "tnTitle");
runOnUiThread(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(mPreviewBaseActivity, pair1, pair2);
ActivityCompat.startActivityForResult(mPreviewBaseActivity, intent, AppConstant.ACTIVITY_REQUEST_CODE, options.toBundle());
CommonUtil.goSleep(2000);
mProgressDialog.dismiss();
} else {
startActivityForResult(intent, AppConstant.ACTIVITY_REQUEST_CODE);
CommonUtil.goSleep(2000);
mProgressDialog.dismiss();
}
}
});
}
ContextView를 사용한 Custom Dialog이며, 화면 전환 시, 알아서 띄워주면 된다.
오늘도 좋은 코딩 되세요 ^^
'Android UI' 카테고리의 다른 글
RadioButton theme 설정으로 pressed 색깔 변경 (1) | 2017.03.14 |
---|