drawable_loading.xml
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/com_loading_fra_ico" android:duration="100" /> <item android:drawable="@drawable/com_loading_jpn_ico" android:duration="100" /> <item android:drawable="@drawable/com_loading_mla_ico" android:duration="100" /> <item android:drawable="@drawable/com_loading_tai" android:duration="100" /> <item android:drawable="@drawable/com_loading_usa_ico" android:duration="100" /> </animation-list> |
drawble_loading_style.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/back_white"/> <size android:width="120dp" android:height="120dp"></size> <corners android:radius="95dp"/> </shape> |
view_ani_loading.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/drawble_loading_style"> <LinearLayout android:layout_width="100dp" android:layout_height="100dp" android:layout_gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/loading_img" android:layout_width="@dimen/dimen50dp" android:layout_height="@dimen/dimen50dp" android:layout_gravity="center" android:background="@drawable/drawable_loading" /> <TextView android:id="@+id/loading_msg" android:layout_marginTop="@dimen/dimen5dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="@dimen/dimen12dp" android:textColor="@color/text_gray" android:layout_gravity="center" android:text="이런 상품은 어때?"/> </LinearLayout>
</RelativeLayout> |
style.xml
<style name="customDialog"> <item name="android:windowFrame">@null</item> <!-- 다이얼로그 테두리 없애기 --> <item name="android:windowBackground">@android:color/transparent</item> <!-- 바탕투명 --> <!-- 다이얼로그라는 것을 알리는 용도라는데.. 여튼 안쓰면 화면 가운데에서 안나옴 --> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> <!-- 타이틀바의 그림자 제거 --> <item name="android:windowTitleStyle">@null</item> <!-- 타이틀바 투명여부 --> <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <!-- 등장 애니메이션 --> <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> <!-- 키보드 때문에 밀림 현상 방지 --> <item name="android:backgroundDimEnabled">false</item> <!-- 다이얼로그 외의 화면을 어둡게 할껀지 말껀지 --> <item name="android:background">@android:color/transparent</item> <!-- 백그라운드 투명 --> </style> |
BaseFrag.java
View loading_view = (View)getAct().getLayoutInflater().inflate(R.layout.view_ani_loading, null); ImageView img = (ImageView)loading_view.findViewById(R.id.loading_img); TextView img_msg = (TextView)loading_view.findViewById(R.id.loading_msg); String[] random_msg = {}; mLoaingDialog = new Dialog(view.getContext(),R.style.customDialog); mLoaingDialog.setContentView(loading_view); mAnim = (AnimationDrawable)img.getBackground(); //img_msg.setText(random_msg[0]);
mCountDownTimer = new CountDownTimer(5,1) { @Override public void onTick(long millisUntilFinished) { }
@Override public void onFinish() { mAnim.stop(); mLoaingDialog.dismiss(); } }; |
통신시작
mAnim.start();
mLoaingDialog.show();
통신끝
mCountDownTimer.start();