首页 > 头条

in progress是什么意思_progressdrawable 环球微资讯

来源:互联网 2023-06-25 11:56:42

1、在anim文件夹下创建sf_progress_dialog_anim.xml,实现旋转的效果:

2、?xml version="1.0" encoding="utf-8"?


(资料图片仅供参考)

3、animation-list xmlns:android="http://schemas.android.com/apk/res/android"

4、 android:oneshot="false"

5、 item

6、 android:drawable="@drawable/sf_progress_1"

7、 android:duration="200"/

8、 item

9、 android:drawable="@drawable/sf_progress_2"

10、 android:duration="200"/

11、 item

12、 android:drawable="@drawable/sf_progress_3"

13、 android:duration="200"/

14、 item

15、 android:drawable="@drawable/sf_progress_4"

16、 android:duration="200"/

17、 item

18、 android:drawable="@drawable/sf_progress_5"

19、 android:duration="200"/

20、 item

21、 android:drawable="@drawable/sf_progress_6"

22、 android:duration="200"/

23、 item

24、 android:drawable="@drawable/sf_progress_7"

25、 android:duration="200"/

26、 item

27、 android:drawable="@drawable/sf_progress_8"

28、 android:duration="60"/

29、/animation-list

30、其中:android:oneshot是指动画只播放一次,停留在最后一帧;当设置为false时,表示动画循环播放;否则,意味着动画只播放一次。

31、可以从以下链接下载资源文件:

32、http://download.csdn.net/detail/shenjichao2008/8248073

33、在values文件夹中创建style.xml以自定义进度对话框的样式:

34、style name="SF_dialogCustom" parent="@android:style/Theme.Dialog"

35、 item name="android:windowFrame"@null/item

36、 item name="android:windowIsFloating"true/item

37、 item name="android:windowContentOverlay"@null/item

38、 item name="android:windowAnimationStyle"@android:style/Animation.Dialog/item

39、 item name="android:windowSoftInputMode"stateUnspecified|adjustPan/item

40、 /style

41、 style name="SF_pressDialogCustom" parent="@style/SF_dialogCustom"

42、 item name="android:windowBackground"@android:color/transparent/item

43、 item name="android:windowNoTitle"true/item

44、 /style

45、Create SF _ view _ custom _ progress _ dialog.xml in the layout folder to customize the layout of progressive dilaog:

46、?xml version="1.0" encoding="utf-8"?

47、LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

48、 android:layout_width="match_parent"

49、 android:layout_height="match_parent"

50、 android:orientation="horizontal"

51、 ImageView

52、 android:id="@+id/sf_iv_progress_dialog_loading"

53、 android:layout_width="wrap_content"

54、 android:layout_height="wrap_content"

55、 android:background="@anim/sf_progress_dialog_anim"

56、 android:contentDescription="@string/sf_progress_dialog_image_loading" /

57、 TextView

58、 android:id="@+id/sf_tv_progress_dialog_loading"

59、 style="@style/SF_MediumLightGreyTxt"

60、 android:layout_width="wrap_content"

61、 android:layout_height="wrap_content"

62、 android:layout_gravity="center_vertical" /

63、/LinearLayout

64、创建SFProgrssDialog类,继承对话框,并按如下方式实现它:

65、package com.snapfish.view;

66、import com.snapfish.R;

67、import android.app.Dialog;

68、import android.content.Context;

69、import android.graphics.drawable.AnimationDrawable;

70、import android.text.TextUtils;

71、import android.view.Gravity;

72、import android.widget.ImageView;

73、import android.widget.TextView;

74、public class SFProgrssDialog extends Dialog {

75、private static SFProgrssDialog m_progrssDialog;

76、private SFProgrssDialog(Context context, int theme) {

77、super(context, theme);

78、}

79、public static SFProgrssDialog createProgrssDialog(Context context) {

80、m_progrssDialog=new SFProgrssDialog(context,

81、R.style.SF_pressDialogCustom);

82、m_progrssDialog.setContentView(R.layout.sf_view_custom_progress_dialog);

83、m_progrssDialog.getWindow().getAttributes().gravity=Gravity.CENTER;

84、return m_progrssDialog;

85、}

86、@Override

87、public void onWindowFocusChanged(boolean hasFocus) {

88、if (null==m_progrssDialog)

89、return;

90、ImageView loadingImageView=(ImageView) m_progrssDialog

91、.findViewById(R.id.sf_iv_progress_dialog_loading);

92、AnimationDrawable animationDrawable=(AnimationDrawable) loadingImageView

93、.getBackground();

94、animationDrawable.start();

95、}

96、public SFProgrssDialog setMessage(String msg) {

97、TextView loadingTextView=(TextView) m_progrssDialog

98、.findViewById(R.id.sf_tv_progress_dialog_loading);

99、if (!TextUtils.isEmpty(msg))

100、loadingTextView.setText(msg);

101、else

102、loadingTextView.setText(R.string.sf_progress_dialog_image_loading);

103、return m_progrssDialog;

104、}

105、}

106、编写一个方法来显示/隐藏进度对话框:

107、private SFProgrssDialog m_customProgrssDialog;

108、final void showCustomProgrssDialog(String msg) {

109、if (null==m_customProgrssDialog)

110、m_customProgrssDialog=SFProgrssDialog

111、.createProgrssDialog(m_parent);

112、if (null !=m_customProgrssDialog) {

113、m_customProgrssDialog.setMessage(msg);

114、m_customProgrssDialog.show();

115、m_customProgrssDialog.setCancelable(false);

116、}

117、}

118、final void hideCustomProgressDialog() {

119、if (null !=m_customProgrssDialog) {

120、m_customProgrssDialog.dismiss();

121、m_customProgrssDialog=null;

122、}

123、}

124、网络请求前,调用showCustomProgrssDialog方法,传入显示的消息;网络响应后,调用hideProgressDialog方法取消进度对话框。

本文到此结束,希望对大家有所帮助。

上一篇

长期燃油修正和短期燃油修正(长期燃油修正过高的原因是什么?)

下一篇

最后一页

为你推荐

最新热文